r18n-core 3.1.1 → 5.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog.md +398 -0
  3. data/README.md +63 -47
  4. data/base/cy.yml +34 -0
  5. data/lib/r18n-core.rb +37 -38
  6. data/lib/r18n-core/filter_list.rb +21 -13
  7. data/lib/r18n-core/filters.rb +43 -48
  8. data/lib/r18n-core/helpers.rb +2 -2
  9. data/lib/r18n-core/i18n.rb +70 -78
  10. data/lib/r18n-core/locale.rb +137 -107
  11. data/lib/r18n-core/locales/af.rb +36 -0
  12. data/lib/r18n-core/locales/az.rb +38 -0
  13. data/lib/r18n-core/locales/bg.rb +29 -0
  14. data/{locales → lib/r18n-core/locales}/ca.rb +9 -6
  15. data/{locales → lib/r18n-core/locales}/cs.rb +15 -11
  16. data/lib/r18n-core/locales/cy.rb +50 -0
  17. data/{locales → lib/r18n-core/locales}/da.rb +10 -7
  18. data/lib/r18n-core/locales/de.rb +33 -0
  19. data/{locales → lib/r18n-core/locales}/en-au.rb +2 -2
  20. data/{locales → lib/r18n-core/locales}/en-gb.rb +2 -2
  21. data/{locales → lib/r18n-core/locales}/en-us.rb +4 -3
  22. data/lib/r18n-core/locales/en.rb +51 -0
  23. data/{locales → lib/r18n-core/locales}/eo.rb +6 -4
  24. data/lib/r18n-core/locales/es-cl.rb +16 -0
  25. data/{locales → lib/r18n-core/locales}/es-us.rb +5 -4
  26. data/{locales → lib/r18n-core/locales}/es.rb +7 -3
  27. data/{locales → lib/r18n-core/locales}/fa.rb +2 -2
  28. data/lib/r18n-core/locales/fi.rb +39 -0
  29. data/lib/r18n-core/locales/fr.rb +39 -0
  30. data/{locales → lib/r18n-core/locales}/gl.rb +5 -3
  31. data/{locales → lib/r18n-core/locales}/hr.rb +13 -10
  32. data/{locales → lib/r18n-core/locales}/hu.rb +10 -7
  33. data/{locales → lib/r18n-core/locales}/id.rb +8 -4
  34. data/lib/r18n-core/locales/it.rb +37 -0
  35. data/{locales → lib/r18n-core/locales}/ja.rb +5 -4
  36. data/{locales → lib/r18n-core/locales}/kk.rb +12 -8
  37. data/{locales → lib/r18n-core/locales}/ko.rb +0 -0
  38. data/lib/r18n-core/locales/lv.rb +46 -0
  39. data/lib/r18n-core/locales/mn.rb +30 -0
  40. data/{locales → lib/r18n-core/locales}/nb.rb +6 -4
  41. data/lib/r18n-core/locales/nl.rb +31 -0
  42. data/{locales → lib/r18n-core/locales}/no.rb +0 -0
  43. data/lib/r18n-core/locales/pl.rb +45 -0
  44. data/{locales → lib/r18n-core/locales}/pt-br.rb +1 -1
  45. data/lib/r18n-core/locales/pt.rb +37 -0
  46. data/lib/r18n-core/locales/ru.rb +46 -0
  47. data/{locales → lib/r18n-core/locales}/sk.rb +13 -9
  48. data/{locales → lib/r18n-core/locales}/sr-latn.rb +10 -8
  49. data/{locales → lib/r18n-core/locales}/sv-se.rb +7 -5
  50. data/lib/r18n-core/locales/th.rb +41 -0
  51. data/{locales → lib/r18n-core/locales}/tr.rb +7 -6
  52. data/lib/r18n-core/locales/uk.rb +31 -0
  53. data/lib/r18n-core/locales/vi.rb +37 -0
  54. data/{locales → lib/r18n-core/locales}/zh-cn.rb +2 -2
  55. data/{locales → lib/r18n-core/locales}/zh-tw.rb +4 -4
  56. data/{locales → lib/r18n-core/locales}/zh.rb +7 -4
  57. data/lib/r18n-core/translated.rb +38 -37
  58. data/lib/r18n-core/translated_string.rb +19 -8
  59. data/lib/r18n-core/translation.rb +24 -19
  60. data/lib/r18n-core/unsupported_locale.rb +14 -6
  61. data/lib/r18n-core/untranslated.rb +23 -7
  62. data/lib/r18n-core/utils.rb +19 -23
  63. data/lib/r18n-core/version.rb +1 -1
  64. data/lib/r18n-core/yaml_loader.rb +17 -13
  65. data/lib/r18n-core/yaml_methods.rb +3 -1
  66. metadata +245 -118
  67. data/.rspec +0 -1
  68. data/Rakefile +0 -13
  69. data/locales/af.rb +0 -32
  70. data/locales/az.rb +0 -34
  71. data/locales/bg.rb +0 -25
  72. data/locales/de.rb +0 -29
  73. data/locales/en.rb +0 -48
  74. data/locales/fi.rb +0 -35
  75. data/locales/fr.rb +0 -35
  76. data/locales/it.rb +0 -34
  77. data/locales/lv.rb +0 -41
  78. data/locales/mn.rb +0 -27
  79. data/locales/nl.rb +0 -28
  80. data/locales/pl.rb +0 -40
  81. data/locales/pt.rb +0 -29
  82. data/locales/ru.rb +0 -41
  83. data/locales/th.rb +0 -37
  84. data/locales/uk.rb +0 -27
  85. data/locales/vi.rb +0 -33
  86. data/r18n-core.gemspec +0 -29
  87. data/spec/filters_spec.rb +0 -324
  88. data/spec/i18n_spec.rb +0 -260
  89. data/spec/locale_spec.rb +0 -216
  90. data/spec/locales/cs_spec.rb +0 -23
  91. data/spec/locales/en-us_spec.rb +0 -13
  92. data/spec/locales/en_spec.rb +0 -13
  93. data/spec/locales/fa_spec.rb +0 -10
  94. data/spec/locales/fr_spec.rb +0 -9
  95. data/spec/locales/hu_spec.rb +0 -17
  96. data/spec/locales/it_spec.rb +0 -10
  97. data/spec/locales/no_spec.rb +0 -9
  98. data/spec/locales/pl_spec.rb +0 -23
  99. data/spec/locales/ru_spec.rb +0 -23
  100. data/spec/locales/sk_spec.rb +0 -23
  101. data/spec/locales/th_spec.rb +0 -9
  102. data/spec/locales/vi_spec.rb +0 -8
  103. data/spec/r18n_spec.rb +0 -172
  104. data/spec/spec_helper.rb +0 -41
  105. data/spec/translated_spec.rb +0 -163
  106. data/spec/translation_spec.rb +0 -164
  107. data/spec/translations/extension/deep/en.yml +0 -1
  108. data/spec/translations/extension/en.yml +0 -2
  109. data/spec/translations/extension/notransl.yml +0 -1
  110. data/spec/translations/general/en.yml +0 -47
  111. data/spec/translations/general/nolocale.yml +0 -6
  112. data/spec/translations/general/ru.yml +0 -7
  113. data/spec/translations/two/en.yml +0 -2
  114. data/spec/translations/two/fr.yml +0 -0
  115. data/spec/yaml_loader_spec.rb +0 -61
@@ -7,21 +7,24 @@ module R18n
7
7
  set(
8
8
  title: '中文',
9
9
 
10
+ sublocales: %w[zh-CN zh-TW],
11
+
10
12
  wday_names: %w[星期日 星期一 星期二 星期三 星期四 星期五 星期六],
11
13
  wday_abbrs: %w[周日 周一 周二 周三 周四 周五 周六],
12
14
 
13
- month_names: %w[一月 二月 三月 四月 五月 六月 七月 八月 九月 十月 十一月
14
- 十二月],
15
+ month_names: %w[
16
+ 一月 二月 三月 四月 五月 六月 七月 八月 九月 十月 十一月 十二月
17
+ ],
15
18
 
16
19
  date_format: '%Y年%m月%d日',
17
20
  full_format: '%m月%d日',
18
21
  year_format: '%Y年_',
19
22
 
20
23
  number_decimal: '.',
21
- number_group: ' '
24
+ number_group: ' '
22
25
  )
23
26
 
24
- def pluralize(_n)
27
+ def pluralize(_number)
25
28
  'n'
26
29
  end
27
30
  end
@@ -22,9 +22,9 @@ module R18n
22
22
  # R18n plugin with out-of-box i18n support.
23
23
  #
24
24
  # Module can add proxy-methods to find translation in object methods. For
25
- # example, if you class have +title_en+ and +title_ru+ methods, you can add
26
- # proxy-method +title+, which will use +title_ru+ for Russian users and
27
- # +title_en+ for English:
25
+ # example, if you class have `title_en` and `title_ru` methods, you can add
26
+ # proxy-method `title`, which will use `title_ru` for Russian users and
27
+ # `title_en` for English:
28
28
  #
29
29
  # class Product
30
30
  # include DataMapper::Resource
@@ -58,21 +58,21 @@ module R18n
58
58
  # Proxy-method support all funtion from I18n: global and type filters,
59
59
  # pluralization, variables. It also return TranslatedString or Untranslated.
60
60
  #
61
- # By default it use <tt>R18n.get</tt> to get I18n object (so, you must set it
62
- # before use model), but you can overwrite object +r18n+ method to change
61
+ # By default it use `R18n.get` to get I18n object (so, you must set it
62
+ # before use model), but you can overwrite object `r18n` method to change
63
63
  # default logic.
64
64
  #
65
65
  # See R18n::Translated::Base for class method documentation.
66
66
  #
67
67
  # == Options
68
68
  # You can set option for proxy-method as Hash with keys;
69
- # * +type+ – YAML type for filters. For example, "markdown" or "escape_html".
70
- # * +methods+ – manual method map as Hash of locale codes to method names.
71
- # * +no_params+ – set it to true if you proxy-method must send it parameters
69
+ # * `type` – YAML type for filters. For example, "markdown" or "escape_html".
70
+ # * `methods` – manual method map as Hash of locale codes to method names.
71
+ # * `no_params` – set it to true if you proxy-method must send it parameters
72
72
  # only to filters.
73
- # * +no_write+ – set it to true if you dont want to create proxy-setters.
73
+ # * `no_write` – set it to true if you don't want to create proxy-setters.
74
74
  #
75
- # Method +translation+ will be more useful for options:
75
+ # Method `translation` will be more useful for options:
76
76
  #
77
77
  # translation :title, methods: { ru: :russian, en: :english}
78
78
  module Translated
@@ -81,54 +81,54 @@ module R18n
81
81
  base.send :extend, Base
82
82
  base.instance_variable_set '@unlocalized_getters', {}
83
83
  base.instance_variable_set '@unlocalized_setters', {}
84
- base.instance_variable_set '@translation_types', {}
85
84
  end
86
85
  end
87
86
 
88
87
  # Access to I18n object. By default return global I18n object from
89
- # <tt>R18n.get</tt>.
88
+ # `R18n.get`.
90
89
  def r18n
91
90
  R18n.get
92
91
  end
93
92
 
94
93
  # Module with class methods, which be added after R18n::Translated include.
95
94
  module Base
96
- # Hash of translation method names to it type for filters.
97
- attr_reader :translation_types
95
+ # `Hash` of translation method names to it type for filters.
96
+ def translation_types
97
+ @translation_types ||= {}
98
+ end
98
99
 
99
- # Add several proxy +methods+. See R18n::Translated for description.
100
- # Its more compact, that +translation+.
100
+ # Add several proxy methods. See `R18n::Translated` for description.
101
+ # It's more compact, that `translation`.
101
102
  #
102
103
  # translations :title, :keywords, [:desciption, { type: 'markdown' }]
103
- def translations(*methods)
104
- methods.each do |method|
105
- translation(*method)
106
- end
104
+ def translations(*names)
105
+ names.each { |name| translation(*name) }
107
106
  end
108
107
 
109
- # Add proxy-method +name+. See R18n::Translated for description.
110
- # Its more useful to set options.
108
+ # Add proxy-method `name`. See `R18n::Translated` for description.
109
+ # It's more useful to set options.
111
110
  #
112
- # translation :desciption, type: 'markdown'
111
+ # translation :description, type: 'markdown'
113
112
  def translation(name, options = {})
114
113
  if options[:methods]
115
- @unlocalized_getters[name] = R18n::Utils
116
- .hash_map(options[:methods]) { |l, i| [l.to_s, i.to_s] }
114
+ @unlocalized_getters[name] =
115
+ options[:methods].map { |l, i| [l.to_s, i.to_s] }.to_h
117
116
  unless options[:no_write]
118
- @unlocalized_setters[name] = R18n::Utils
119
- .hash_map(options[:methods]) { |l, i| [l.to_s, i.to_s + '='] }
117
+ @unlocalized_setters[name] =
118
+ options[:methods].map { |l, i| [l.to_s, "#{i}="] }.to_h
120
119
  end
121
120
  end
122
121
 
123
- @translation_types[name] = options[:type]
122
+ translation_types[name] = options[:type]
124
123
 
125
124
  define_method name do |*params|
126
125
  unlocalized = self.class.unlocalized_getters(name)
127
126
  result = nil
128
127
 
129
128
  r18n.locales.each do |locale|
130
- code = locale.code
129
+ code = locale.downcased_code
131
130
  next unless unlocalized.key? code
131
+
132
132
  result = send(
133
133
  unlocalized[code], *(params unless options[:no_params])
134
134
  )
@@ -160,22 +160,23 @@ module R18n
160
160
  r18n.locales.each do |locale|
161
161
  code = locale.code
162
162
  next unless unlocalized.key? code
163
+
163
164
  return send unlocalized[code], *params
164
165
  end
165
166
  end
166
167
  end
167
168
 
168
- # Return array of methods to find +unlocalized_getters+ or
169
- # +unlocalized_setters+.
169
+ # Return array of methods to find `unlocalized_getters` or
170
+ # `unlocalized_setters`.
170
171
  def unlocalized_methods
171
172
  instance_methods
172
173
  end
173
174
 
174
- # Return Hash of locale code to getter method for proxy +method+. If you
175
- # didnt set map in +translation+ option +methods+, it will be detect
175
+ # Return `Hash` of locale code to getter method for proxy `method`. If you
176
+ # didn't set map in `translation` option `methods`, it will be detect
176
177
  # automatically.
177
178
  def unlocalized_getters(method)
178
- matcher = Regexp.new('^' + Regexp.escape(method.to_s) + '_(\w+)$')
179
+ matcher = Regexp.new("^#{Regexp.escape(method.to_s)}_(\\w+)$")
179
180
  unless @unlocalized_getters.key? method
180
181
  @unlocalized_getters[method] = {}
181
182
  unlocalized_methods.select { |i| i =~ matcher }.each do |i|
@@ -185,11 +186,11 @@ module R18n
185
186
  @unlocalized_getters[method]
186
187
  end
187
188
 
188
- # Return Hash of locale code to setter method for proxy +method+. If you
189
- # didnt set map in +translation+ option +methods+, it will be detect
189
+ # Return `Hash` of locale code to setter method for proxy `method`. If you
190
+ # didn't set map in `translation` option `methods`, it will be detect
190
191
  # automatically.
191
192
  def unlocalized_setters(method)
192
- matcher = Regexp.new('^' + Regexp.escape(method.to_s) + '_(\w+)=$')
193
+ matcher = Regexp.new("^#{Regexp.escape(method.to_s)}_(\\w+)=$")
193
194
  unless @unlocalized_setters.key? method
194
195
  @unlocalized_setters[method] = {}
195
196
  unlocalized_methods.select { |i| i =~ matcher }.each do |i|
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'untranslated'
4
+
3
5
  # Translation string for i18n support.
4
6
  #
5
7
  # Copyright (C) 2008 Andrey “A.I.” Sitnik <andrey@sitnik.ru>
@@ -26,8 +28,8 @@ module R18n
26
28
  # Path for this translation.
27
29
  attr_reader :path
28
30
 
29
- # Returns a new string object containing a copy of +str+, which translated
30
- # for +path+ to +locale+
31
+ # Returns a new string object containing a copy of `str`, which translated
32
+ # for `path` to `locale`
31
33
  def initialize(value, locale, path, filters = nil)
32
34
  super(value.to_s)
33
35
  @filters = filters
@@ -45,14 +47,9 @@ module R18n
45
47
  true
46
48
  end
47
49
 
48
- # Return true if `html_safe` method is defined, otherwise false.
49
- def html_safe?
50
- respond_to? :html_safe
51
- end
52
-
53
50
  # Override to_s to make string html safe if `html_safe` method is defined.
54
51
  def to_s
55
- if respond_to? :html_safe
52
+ if respond_to?(:html_safe)
56
53
  super.html_safe
57
54
  else
58
55
  String.new(super)
@@ -82,9 +79,23 @@ module R18n
82
79
  Untranslated.new(translated, key, @locale, @filters)
83
80
  end
84
81
 
82
+ NON_KEYS_METHODS = [
83
+ *Untranslated::NON_KEYS_METHODS,
84
+ :html_safe,
85
+ :to_text
86
+ ].freeze
87
+
85
88
  # Return untranslated, when user try to go deeper in translation.
86
89
  def method_missing(name, *_params)
90
+ return super if NON_KEYS_METHODS.include?(name)
91
+
87
92
  get_untranslated(name.to_s)
88
93
  end
94
+
95
+ def respond_to_missing?(name, *args)
96
+ return super if NON_KEYS_METHODS.include?(name)
97
+
98
+ true
99
+ end
89
100
  end
90
101
  end
@@ -23,16 +23,16 @@ module R18n
23
23
 
24
24
  # Translation is container of translated messages.
25
25
  #
26
- # You can load several locales and if translation willnt be found in first,
26
+ # You can load several locales and if translation willn't be found in first,
27
27
  # r18n will be search it in next. Use R18n::I18n.new to load translations.
28
28
  #
29
29
  # To get translation value use method with same name. If translation name
30
- # is equal with Object methods (+new+, +to_s+, +methods+) use
31
- # <tt>[name, params…]</tt>. If you want to get pluralizable value, just set
30
+ # is equal with Object methods (`new`, `to_s`, `methods`) use
31
+ # `[name, params…]`. If you want to get pluralizable value, just set
32
32
  # value for pluralization in first argument of method. See samples below.
33
33
  #
34
- # Translated strings will have +locale+ methods, which return Locale or
35
- # UnsupportedLocale, if locale file isnt exists.
34
+ # Translated strings will have `locale` methods, which return Locale or
35
+ # UnsupportedLocale, if locale file isn't exists.
36
36
  #
37
37
  # == Examples
38
38
  # translations/ru.yml
@@ -51,7 +51,7 @@ module R18n
51
51
  # comments: !!pl
52
52
  # 0: no comments
53
53
  # 1: one comment
54
- # n: %1 comments
54
+ # n: '%1 comments'
55
55
  #
56
56
  # example.rb
57
57
  #
@@ -68,7 +68,7 @@ module R18n
68
68
  # i18n.comments(10) #=> "10 comments"
69
69
  class Translation
70
70
  # This is internal a constructor. To load translation use
71
- # <tt>R18n::I18n.new(locales, translations_dir)</tt>.
71
+ # `R18n::I18n.new(locales, translations_dir)`.
72
72
  def initialize(locale, path = '', options = {})
73
73
  @data = {}
74
74
  @locale = locale
@@ -78,8 +78,8 @@ module R18n
78
78
  merge! options[:translations], options[:locale] if options[:translations]
79
79
  end
80
80
 
81
- # Add another hash with +translations+ for some +locale+. Current data is
82
- # more priority, that new one in +translations+.
81
+ # Add another hash with `translations` for some `locale`. Current data is
82
+ # more priority, that new one in `translations`.
83
83
  def merge!(translations, locale)
84
84
  (translations || {}).each_pair do |name, value|
85
85
  if !@data.key?(name)
@@ -123,28 +123,27 @@ module R18n
123
123
 
124
124
  # Return current translation keys.
125
125
  #
126
- # Deprecated. Use <tt>to_hash.keys</tt>.
126
+ # Deprecated. Use `to_hash.keys`.
127
127
  def translation_keys
128
128
  to_hash.keys
129
129
  end
130
130
 
131
131
  # Return hash of current translation node.
132
132
  def to_hash
133
- Utils.hash_map(@data) do |key, value|
134
- value = value.to_hash if value.is_a? Translation
135
- [key, value]
133
+ @data.transform_values do |value|
134
+ value.is_a?(Translation) ? value.to_hash : value
136
135
  end
137
136
  end
138
137
 
139
- # Return +default+.
138
+ # Return `default`.
140
139
  def |(other)
141
140
  other
142
141
  end
143
142
 
144
- # Return translation with special +name+.
143
+ # Return translation with special `name`.
145
144
  #
146
- # Translation can contain variable part. Just set is as <tt>%1</tt>,
147
- # <tt>%2</tt>, etc in translations file and set values in next +params+.
145
+ # Translation can contain variable part. Just set is as `%1`,
146
+ # `%2`, etc in translations file and set values in next `params`.
148
147
  def [](name, *params)
149
148
  unless [String, Integer, TrueClass, FalseClass]
150
149
  .any? { |klass| name.is_a?(klass) }
@@ -166,10 +165,16 @@ module R18n
166
165
  end
167
166
  alias method_missing []
168
167
 
169
- # Return translation located at +names+.
168
+ # Return translation located at `keys`.
170
169
  # @see Hash#dig
171
170
  def dig(*keys)
172
- keys.reduce(self) { |result, key| result[key] }
171
+ keys.reduce(self, :[])
172
+ end
173
+
174
+ # I think we don't need in the Ruby core method,
175
+ # but it can be handy as a key
176
+ def itself
177
+ self[__method__]
173
178
  end
174
179
  end
175
180
  end
@@ -24,10 +24,13 @@ module R18n
24
24
  # Locale, to get data and pluralization for unsupported locale.
25
25
  attr_accessor :base
26
26
 
27
- # Create object for unsupported locale with +code+ and load other locale
28
- # data from +base+ locale.
27
+ attr_reader :code, :downcased_code
28
+
29
+ # Create object for unsupported locale with `code` and load other locale
30
+ # data from `base` locale.
29
31
  def initialize(code, _base = nil)
30
32
  @code = code
33
+ @downcased_code = @code.downcase.tr('-', '_').freeze
31
34
  @base = Locale.load(I18n.default) if @code != I18n.default
32
35
  end
33
36
 
@@ -41,9 +44,6 @@ module R18n
41
44
  "Unsupported locale #{@code}"
42
45
  end
43
46
 
44
- # Locale RFC 3066 code.
45
- attr_reader :code
46
-
47
47
  # Locale code as title.
48
48
  def title
49
49
  @code
@@ -56,7 +56,15 @@ module R18n
56
56
 
57
57
  # Proxy to default locale object.
58
58
  def method_missing(name, *params)
59
- @base.send(name, *params)
59
+ return super unless @base.respond_to? name
60
+
61
+ @base.public_send(name, *params)
62
+ end
63
+
64
+ def respond_to_missing?(name, *args)
65
+ return super unless @base
66
+
67
+ @base.send __method__, name, *args
60
68
  end
61
69
  end
62
70
  end
@@ -18,7 +18,7 @@
18
18
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
19
 
20
20
  module R18n
21
- # Return if translation isnt exists. Unlike nil, it didnt raise error when
21
+ # Return if translation isn't exists. Unlike nil, it didn't raise error when
22
22
  # you try to access for subtranslations.
23
23
  #
24
24
  # You can set format to print untranslated string by filters. For example:
@@ -37,7 +37,7 @@ module R18n
37
37
  #
38
38
  # R18n::Filters.add(R18n::Untranslated, :hide_untranslated) { '' }
39
39
  class Untranslated
40
- # Path, that isnt in translation.
40
+ # Path, that isn't in translation.
41
41
  attr_reader :untranslated_path
42
42
 
43
43
  # Path, that exists in translation.
@@ -73,18 +73,33 @@ module R18n
73
73
  new arr[1], arr[2], R18n.locale(arr[0]), GlobalFilterList.instance
74
74
  end
75
75
 
76
+ NON_KEYS_METHODS = %i[
77
+ to_ary
78
+ to_hash
79
+ marshal_dump
80
+ marshal_load
81
+ ].freeze
82
+
76
83
  def method_missing(name, *_params)
77
84
  # It is need to fix some hack in specs
78
- if name == :to_ary
79
- raise NoMethodError, "undefined method `to_ary' for #{self}"
80
- end
85
+ return super if NON_KEYS_METHODS.include?(name)
81
86
 
82
87
  self[name]
83
88
  end
84
89
 
90
+ def respond_to_missing?(name, *args)
91
+ return super if NON_KEYS_METHODS.include?(name)
92
+
93
+ true
94
+ end
95
+
85
96
  def [](*params)
86
- Untranslated.new(translated_path, "#{@untranslated_path}.#{params.first}",
87
- @locale, @filters)
97
+ Untranslated.new(
98
+ translated_path,
99
+ "#{@untranslated_path}.#{params.first}",
100
+ @locale,
101
+ @filters
102
+ )
88
103
  end
89
104
 
90
105
  def |(other)
@@ -106,6 +121,7 @@ module R18n
106
121
  return false unless locale == other.locale
107
122
  return false unless translated_path == other.translated_path
108
123
  return false unless untranslated_path == other.untranslated_path
124
+
109
125
  true
110
126
  end
111
127
  end