i18n 1.13.0 → 1.14.0

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: e85066f2cf6bbf170ff946391c6037d0335e5314d0c1e0723e980d5ee7df7af0
4
- data.tar.gz: 2a4629aa0644c2a6e8cc5d175d4912b5f5cd4abc066dd5ee196270b7a3eadd08
3
+ metadata.gz: 56f42c8544a7ce959616902c3a1dcabe350581001f708b43883504995c29835a
4
+ data.tar.gz: 8502fbd1b16386dc75b9feac93e023915671ade132423b04538324e8c855de8c
5
5
  SHA512:
6
- metadata.gz: '01326189eb7b675594bd63c802ae9470135e9aab222de4df1429c99c585b9b59b172ed62386c03b82fd45c862bbb42484dc89e0289c83970315f9a5fa03ba91c'
7
- data.tar.gz: 290489ae277759fe65197e65d6486b7cca67605c2c98197a472c91bb2496d9db168dfd2082706b87f6f806051827b8df12cc0037258f3bf10d5f74a9ddb9f575
6
+ metadata.gz: 8b19cf52d0c49c3f521d3917958b47a235d61d374af806ade81da6092bf68577153012cf98cb61c85b4f951284a96aeace9280c8ca64d78e6f0b7546ef3f8d64
7
+ data.tar.gz: ac025237950bb63b2f66ff28ceb9cadb9de16bd9b55853ee47a48f61552c5192805bbc4415e4f8394481c74130c8163938707cf861ad65d58438636be096ccae
@@ -98,7 +98,7 @@ module I18n
98
98
  # Parse the load path and extract all locales.
99
99
  def available_locales
100
100
  if lazy_load?
101
- I18n.load_path.map { |path| LocaleExtractor.locale_from_path(path) }
101
+ I18n.load_path.map { |path| LocaleExtractor.locale_from_path(path) }.uniq
102
102
  else
103
103
  super
104
104
  end
@@ -47,7 +47,7 @@ module I18n
47
47
 
48
48
  class MissingTranslation < ArgumentError
49
49
  module Base
50
- PERMITTED_KEYS = [:scope].freeze
50
+ PERMITTED_KEYS = [:scope, :default].freeze
51
51
 
52
52
  attr_reader :locale, :key, :options
53
53
 
@@ -63,8 +63,18 @@ module I18n
63
63
  end
64
64
 
65
65
  def message
66
- "translation missing: #{keys.join('.')}"
66
+ if options[:default].is_a?(Array)
67
+ other_options = ([key, *options[:default]]).map { |k| normalized_option(k).prepend('- ') }.join("\n")
68
+ "Translation missing. Options considered were:\n#{other_options}"
69
+ else
70
+ "Translation missing: #{keys.join('.')}"
71
+ end
72
+ end
73
+
74
+ def normalized_option(key)
75
+ I18n.normalize_keys(locale, key, options[:scope]).join('.')
67
76
  end
77
+
68
78
  alias :to_s :message
69
79
 
70
80
  def to_exception
@@ -64,7 +64,7 @@ module I18n
64
64
  end
65
65
 
66
66
  test "localize Date: given missing translations it returns the correct error message" do
67
- assert_equal 'translation missing: fr.date.abbr_month_names', I18n.l(@date, :format => '%b', :locale => :fr)
67
+ assert_equal 'Translation missing: fr.date.abbr_month_names', I18n.l(@date, :format => '%b', :locale => :fr)
68
68
  end
69
69
 
70
70
  test "localize Date: given an unknown format it does not fail" do
@@ -60,7 +60,7 @@ module I18n
60
60
  end
61
61
 
62
62
  test "localize DateTime: given missing translations it returns the correct error message" do
63
- assert_equal 'translation missing: fr.date.abbr_month_names', I18n.l(@datetime, :format => '%b', :locale => :fr)
63
+ assert_equal 'Translation missing: fr.date.abbr_month_names', I18n.l(@datetime, :format => '%b', :locale => :fr)
64
64
  end
65
65
 
66
66
  test "localize DateTime: given a meridian indicator format it returns the correct meridian indicator" do
@@ -61,7 +61,7 @@ module I18n
61
61
  end
62
62
 
63
63
  test "localize Time: given missing translations it returns the correct error message" do
64
- assert_equal 'translation missing: fr.date.abbr_month_names', I18n.l(@time, :format => '%b', :locale => :fr)
64
+ assert_equal 'Translation missing: fr.date.abbr_month_names', I18n.l(@time, :format => '%b', :locale => :fr)
65
65
  end
66
66
 
67
67
  test "localize Time: given a meridian indicator format it returns the correct meridian indicator" do
@@ -30,7 +30,7 @@ module I18n
30
30
  end
31
31
 
32
32
  test "lookup: given a missing key, no default and no raise option it returns an error message" do
33
- assert_equal "translation missing: en.missing", I18n.t(:missing)
33
+ assert_equal "Translation missing: en.missing", I18n.t(:missing)
34
34
  end
35
35
 
36
36
  test "lookup: given a missing key, no default and the raise option it raises MissingTranslationData" do
data/lib/i18n/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module I18n
4
- VERSION = "1.13.0"
4
+ VERSION = "1.14.0"
5
5
  end
data/lib/i18n.rb CHANGED
@@ -331,11 +331,12 @@ module I18n
331
331
  # keys are Symbols.
332
332
  def normalize_keys(locale, key, scope, separator = nil)
333
333
  separator ||= I18n.default_separator
334
- locale = locale.to_sym if locale
335
334
 
336
- result = [locale]
337
- result.concat(normalize_key(scope, separator)) if scope
338
- result.concat(normalize_key(key, separator))
335
+ [
336
+ *normalize_key(locale, separator),
337
+ *normalize_key(scope, separator),
338
+ *normalize_key(key, separator)
339
+ ]
339
340
  end
340
341
 
341
342
  # Returns true when the passed locale, which can be either a String or a
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i18n
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.13.0
4
+ version: 1.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sven Fuchs
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2023-04-26 00:00:00.000000000 Z
16
+ date: 2023-06-02 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: concurrent-ruby