i18nliner 0.2.2 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f9f3816293c70dfd95ca1cd66cb80d611f283c416e2dc0bd9eec08723d33f32e
4
- data.tar.gz: e41ce0ba376064862cc64d063b2ac2cdf48002136446079f403255e9cb6a69b9
3
+ metadata.gz: 3cae685053ab3a06d205244fb111de3040ca1d81224d099e2350f016d07f0d55
4
+ data.tar.gz: f41863a6a11fffc2839cae6bbf5c4fb98c67e7f71a6b8524b9f5aa49bbee1b26
5
5
  SHA512:
6
- metadata.gz: b31d8fdd70c548e770d92584e9c35f6ce15ca60a6bc8a1d835cb2b90653b6de63029d35fcd2465245d473f1cab5914634a290faa344c8a5ec0e115dfcb4947b1
7
- data.tar.gz: 90a338c6438b59dfa6b0f51af4f4c97b747b068390e975f68e8a6af9ba5ddf3b0c735ffc2e46ca7fe63effc8c5ce2f037e6a808b6a50ae197a9d5110a5088895
6
+ metadata.gz: 4b89963344f03ce3f822a917ad6005278763ef23aeead3044d5dd06160cc3583b2ae9662baa5113dddf870e9dd5dd0bd279c2c6d2e7decdd54682a68ec4e1d4a
7
+ data.tar.gz: 970fa32baf0fb3bb378d793f664296d67ea2199ba0e6bc8193f4b72eeb12a4917b944742b8d4b9766c942fc54525183c864b4b84c77488c3852766d165bb06ad
@@ -13,7 +13,7 @@ module I18nliner
13
13
  key, options = CallHelpers.infer_arguments(args)
14
14
  options = inferpolate(options) if I18nliner.infer_interpolation_values
15
15
  options[:i18nliner_scope] = i18nliner_scope
16
- super(key, options)
16
+ super(key, **options)
17
17
  end
18
18
  alias :t :translate
19
19
  alias :t! :translate
@@ -17,7 +17,7 @@ module I18nliner
17
17
  end
18
18
 
19
19
  wrappers = options.delete(:wrappers) || options.delete(:wrapper)
20
- result = super(key, options)
20
+ result = super(key, **options)
21
21
 
22
22
  # Exit now unless we have a string or a thing that delegates to a string
23
23
  return result unless result.respond_to?(:gsub)
@@ -13,7 +13,7 @@ module I18nliner
13
13
  key, options = CallHelpers.infer_arguments(args)
14
14
  options = inferpolate(options) if I18nliner.infer_interpolation_values
15
15
  options[:i18nliner_scope] = i18nliner_scope
16
- I18n.translate(key, options)
16
+ I18n.translate(key, **options)
17
17
  end
18
18
  alias :t :translate
19
19
  alias :t! :translate
@@ -17,7 +17,7 @@ module I18nliner
17
17
  key, options = CallHelpers.infer_arguments(args)
18
18
  options = inferpolate(options) if I18nliner.infer_interpolation_values
19
19
  options[:i18nliner_scope] = i18nliner_scope
20
- super(key, options)
20
+ super(key, **options)
21
21
  rescue ArgumentError
22
22
  raise
23
23
  end
@@ -84,6 +84,9 @@ module I18nliner
84
84
  end
85
85
 
86
86
  def evaluate_expression(exp)
87
+ # value omissions in hashes will be nil and can just be considered UnsupportedExpression
88
+ # since they are equivalent to a method call
89
+ return UnsupportedExpression if exp.nil?
87
90
  return raw(exp) if exp.sexp_type == :lit
88
91
  return string_from(exp) if stringish?(exp)
89
92
  return hash_from(exp) if exp.sexp_type == :hash
@@ -8,7 +8,7 @@ describe I18nliner::Extensions::Controller do
8
8
  extend(Module.new do
9
9
  def translate(key, options)
10
10
  options.delete(:i18nliner_inferred_key)
11
- I18n.translate(key, options)
11
+ I18n.translate(key, **options)
12
12
  end
13
13
 
14
14
  def controller_name
@@ -5,11 +5,15 @@ describe I18nliner::Extensions::Core do
5
5
  let(:i18n) do
6
6
  Module.new do
7
7
  extend(Module.new do
8
- def translate(*args)
9
- simple_translate(args[0], args[1])
8
+ def translate(key, **options)
9
+ if RUBY_VERSION >= '3.0'
10
+ simple_translate(key, **options)
11
+ else
12
+ simple_translate(key, options)
13
+ end
10
14
  end
11
15
 
12
- def simple_translate(key, options)
16
+ def simple_translate(key, **options)
13
17
  string = options.delete(:default)
14
18
  interpolate_hash(string, options)
15
19
  end
@@ -48,7 +52,11 @@ describe I18nliner::Extensions::Core do
48
52
  end
49
53
 
50
54
  it "should stringify array keys, but not the array itself" do
51
- expect(i18n).to receive(:simple_translate).with(["bar", "baz"], {})
55
+ if RUBY_VERSION >= '3.0'
56
+ expect(i18n).to receive(:simple_translate).with(["bar", "baz"])
57
+ else
58
+ expect(i18n).to receive(:simple_translate).with(["bar", "baz"], {})
59
+ end
52
60
  i18n.translate([:bar, :baz])
53
61
  end
54
62
 
@@ -6,9 +6,9 @@ describe I18nliner::Extensions::View do
6
6
  let(:i18n) do
7
7
  Module.new do
8
8
  extend(Module.new do
9
- def translate(key, options)
9
+ def translate(key, **options)
10
10
  options.delete(:i18nliner_inferred_key)
11
- I18n.translate(key, options)
11
+ I18n.translate(key, **options)
12
12
  end
13
13
  end)
14
14
  extend I18nliner::Extensions::View
@@ -49,6 +49,10 @@ describe I18nliner::Extractors::RubyExtractor do
49
49
  {'foo' => "Foo"})
50
50
  end
51
51
 
52
+ it "should handle omitted values in hashes" do
53
+ expect { extract("t('foo %{count}', count:)") }.not_to raise_error
54
+ end
55
+
52
56
  it "should bail on invalid t calls" do
53
57
  assert_error "t foo", I18nliner::InvalidSignatureError
54
58
  assert_error "t :foo, foo", I18nliner::InvalidSignatureError
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i18nliner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Jensen
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-10 00:00:00.000000000 Z
11
+ date: 2023-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '6.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: i18n
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.8.6
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 1.8.6
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: ruby_parser
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -210,7 +224,7 @@ files:
210
224
  homepage: http://github.com/jenseng/i18nliner
211
225
  licenses: []
212
226
  metadata: {}
213
- post_install_message:
227
+ post_install_message:
214
228
  rdoc_options: []
215
229
  require_paths:
216
230
  - lib
@@ -226,7 +240,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
226
240
  version: 1.3.5
227
241
  requirements: []
228
242
  rubygems_version: 3.1.6
229
- signing_key:
243
+ signing_key:
230
244
  specification_version: 4
231
245
  summary: I18n made simple
232
246
  test_files: []