r18n-core 2.2.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. checksums.yaml +5 -5
  2. data/.rspec +1 -1
  3. data/ChangeLog.md +6 -1
  4. data/README.md +1 -20
  5. data/Rakefile +5 -3
  6. data/lib/r18n-core.rb +55 -55
  7. data/lib/r18n-core/filter_list.rb +34 -36
  8. data/lib/r18n-core/filters.rb +68 -51
  9. data/lib/r18n-core/helpers.rb +17 -17
  10. data/lib/r18n-core/i18n.rb +46 -39
  11. data/lib/r18n-core/locale.rb +79 -70
  12. data/lib/r18n-core/translated.rb +65 -66
  13. data/lib/r18n-core/translated_string.rb +24 -24
  14. data/lib/r18n-core/translation.rb +31 -30
  15. data/lib/r18n-core/unsupported_locale.rb +22 -24
  16. data/lib/r18n-core/untranslated.rb +35 -33
  17. data/lib/r18n-core/utils.rb +26 -25
  18. data/lib/r18n-core/version.rb +4 -1
  19. data/lib/r18n-core/yaml_loader.rb +26 -25
  20. data/lib/r18n-core/yaml_methods.rb +25 -28
  21. data/locales/af.rb +15 -8
  22. data/locales/az.rb +19 -12
  23. data/locales/bg.rb +16 -9
  24. data/locales/ca.rb +16 -9
  25. data/locales/cs.rb +27 -20
  26. data/locales/da.rb +15 -8
  27. data/locales/de.rb +16 -9
  28. data/locales/en-au.rb +10 -5
  29. data/locales/en-gb.rb +12 -5
  30. data/locales/en-us.rb +12 -5
  31. data/locales/en.rb +29 -22
  32. data/locales/eo.rb +14 -7
  33. data/locales/es-us.rb +12 -5
  34. data/locales/es.rb +14 -7
  35. data/locales/fa.rb +48 -32
  36. data/locales/fi.rb +19 -12
  37. data/locales/fr.rb +22 -15
  38. data/locales/gl.rb +15 -8
  39. data/locales/hr.rb +24 -17
  40. data/locales/hu.rb +28 -21
  41. data/locales/id.rb +14 -7
  42. data/locales/it.rb +21 -14
  43. data/locales/ja.rb +15 -8
  44. data/locales/kk.rb +17 -10
  45. data/locales/ko.rb +15 -9
  46. data/locales/lv.rb +24 -17
  47. data/locales/mn.rb +10 -3
  48. data/locales/nb.rb +15 -8
  49. data/locales/nl.rb +15 -8
  50. data/locales/no.rb +11 -16
  51. data/locales/pl.rb +26 -19
  52. data/locales/pt-br.rb +12 -5
  53. data/locales/pt.rb +17 -10
  54. data/locales/ru.rb +26 -19
  55. data/locales/sk.rb +27 -20
  56. data/locales/sr-latn.rb +27 -22
  57. data/locales/sv-se.rb +15 -8
  58. data/locales/th.rb +27 -20
  59. data/locales/tr.rb +16 -9
  60. data/locales/uk.rb +19 -12
  61. data/locales/vi.rb +14 -7
  62. data/locales/zh-cn.rb +12 -5
  63. data/locales/zh-tw.rb +15 -8
  64. data/locales/zh.rb +14 -7
  65. data/r18n-core.gemspec +5 -3
  66. data/spec/filters_spec.rb +71 -67
  67. data/spec/i18n_spec.rb +73 -51
  68. data/spec/locale_spec.rb +73 -68
  69. data/spec/locales/cs_spec.rb +2 -2
  70. data/spec/locales/en-us_spec.rb +9 -9
  71. data/spec/locales/en_spec.rb +2 -2
  72. data/spec/locales/fa_spec.rb +3 -3
  73. data/spec/locales/fr_spec.rb +2 -2
  74. data/spec/locales/hu_spec.rb +7 -7
  75. data/spec/locales/it_spec.rb +3 -3
  76. data/spec/locales/no_spec.rb +9 -0
  77. data/spec/locales/pl_spec.rb +2 -2
  78. data/spec/locales/ru_spec.rb +2 -2
  79. data/spec/locales/sk_spec.rb +2 -2
  80. data/spec/locales/th_spec.rb +2 -2
  81. data/spec/locales/vi_spec.rb +2 -2
  82. data/spec/r18n_spec.rb +44 -38
  83. data/spec/spec_helper.rb +13 -9
  84. data/spec/translated_spec.rb +48 -31
  85. data/spec/translation_spec.rb +29 -27
  86. data/spec/translations/general/en.yml +0 -2
  87. data/spec/yaml_loader_spec.rb +22 -18
  88. metadata +5 -3
@@ -1,21 +1,21 @@
1
- =begin
2
- Add i18n support to any class.
3
-
4
- Copyright (C) 2008 Andrey “A.I.” Sitnik <andrey@sitnik.ru>
5
-
6
- This program is free software: you can redistribute it and/or modify
7
- it under the terms of the GNU Lesser General Public License as published by
8
- the Free Software Foundation, either version 3 of the License, or
9
- (at your option) any later version.
10
-
11
- This program is distributed in the hope that it will be useful,
12
- but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- GNU Lesser General Public License for more details.
15
-
16
- You should have received a copy of the GNU Lesser General Public License
17
- along with this program. If not, see <http://www.gnu.org/licenses/>.
18
- =end
1
+ # frozen_string_literal: true
2
+
3
+ # Add i18n support to any class.
4
+ #
5
+ # Copyright (C) 2008 Andrey “A.I.” Sitnik <andrey@sitnik.ru>
6
+ #
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser General Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser General Public License
18
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
19
 
20
20
  module R18n
21
21
  # Module to add i18n support to any class. It will be useful for ORM or
@@ -112,64 +112,63 @@ module R18n
112
112
  # translation :desciption, type: 'markdown'
113
113
  def translation(name, options = {})
114
114
  if options[:methods]
115
- @unlocalized_getters[name] = R18n::Utils.
116
- hash_map(options[:methods]) { |l, i| [ l.to_s, i.to_s ] }
115
+ @unlocalized_getters[name] = R18n::Utils
116
+ .hash_map(options[:methods]) { |l, i| [l.to_s, i.to_s] }
117
117
  unless options[:no_write]
118
- @unlocalized_setters[name] = R18n::Utils.
119
- hash_map(options[:methods]) { |l, i| [ l.to_s, i.to_s + '=' ] }
118
+ @unlocalized_setters[name] = R18n::Utils
119
+ .hash_map(options[:methods]) { |l, i| [l.to_s, i.to_s + '='] }
120
120
  end
121
121
  end
122
122
 
123
123
  @translation_types[name] = options[:type]
124
- params = options[:no_params] ? '' : ', *params'
125
-
126
- class_eval <<-EOS, __FILE__, __LINE__
127
- def #{name}(*params)
128
- unlocalized = self.class.unlocalized_getters(#{name.inspect})
129
- result = nil
130
-
131
- r18n.locales.each do |locale|
132
- code = locale.code
133
- next unless unlocalized.has_key? code
134
- result = send unlocalized[code]#{params}
135
- next unless result
136
-
137
- path = "\#{self.class.name}##{name}"
138
- type = self.class.translation_types[#{name.inspect}]
139
- if type
140
- return r18n.filter_list.process(:all, type, result, locale,
141
- path, params)
142
- elsif result.is_a? String
143
- result = TranslatedString.new(result, locale, path)
144
- return r18n.filter_list.process_string(:all, result, path,
145
- params)
146
- else
147
- return result
148
- end
124
+
125
+ define_method name do |*params|
126
+ unlocalized = self.class.unlocalized_getters(name)
127
+ result = nil
128
+
129
+ r18n.locales.each do |locale|
130
+ code = locale.code
131
+ next unless unlocalized.key? code
132
+ result = send(
133
+ unlocalized[code], *(params unless options[:no_params])
134
+ )
135
+ next unless result
136
+
137
+ path = "#{self.class.name}##{name}"
138
+ type = self.class.translation_types[name]
139
+ if type
140
+ return r18n.filter_list.process(
141
+ :all, type, result, locale, path, params
142
+ )
143
+ elsif result.is_a? String
144
+ result = TranslatedString.new(result, locale, path)
145
+ return r18n.filter_list.process_string(
146
+ :all, result, path, params
147
+ )
148
+ else
149
+ return result
149
150
  end
151
+ end
152
+
153
+ result
154
+ end
150
155
 
151
- result
156
+ return if options[:no_write]
157
+
158
+ define_method "#{name}=" do |*params|
159
+ unlocalized = self.class.unlocalized_setters(name)
160
+ r18n.locales.each do |locale|
161
+ code = locale.code
162
+ next unless unlocalized.key? code
163
+ return send unlocalized[code], *params
152
164
  end
153
- EOS
154
-
155
- unless options[:no_write]
156
- class_eval <<-EOS, __FILE__, __LINE__
157
- def #{name}=(*params)
158
- unlocalized = self.class.unlocalized_setters(#{name.inspect})
159
- r18n.locales.each do |locale|
160
- code = locale.code
161
- next unless unlocalized.has_key? code
162
- return send unlocalized[code], *params
163
- end
164
- end
165
- EOS
166
165
  end
167
166
  end
168
167
 
169
168
  # Return array of methods to find +unlocalized_getters+ or
170
169
  # +unlocalized_setters+.
171
170
  def unlocalized_methods
172
- self.instance_methods
171
+ instance_methods
173
172
  end
174
173
 
175
174
  # Return Hash of locale code to getter method for proxy +method+. If you
@@ -177,9 +176,9 @@ module R18n
177
176
  # automatically.
178
177
  def unlocalized_getters(method)
179
178
  matcher = Regexp.new('^' + Regexp.escape(method.to_s) + '_(\w+)$')
180
- unless @unlocalized_getters.has_key? method
179
+ unless @unlocalized_getters.key? method
181
180
  @unlocalized_getters[method] = {}
182
- self.unlocalized_methods.reject { |i| not i =~ matcher }.each do |i|
181
+ unlocalized_methods.select { |i| i =~ matcher }.each do |i|
183
182
  @unlocalized_getters[method][i.to_s.match(matcher)[1]] = i.to_s
184
183
  end
185
184
  end
@@ -191,9 +190,9 @@ module R18n
191
190
  # automatically.
192
191
  def unlocalized_setters(method)
193
192
  matcher = Regexp.new('^' + Regexp.escape(method.to_s) + '_(\w+)=$')
194
- unless @unlocalized_setters.has_key? method
193
+ unless @unlocalized_setters.key? method
195
194
  @unlocalized_setters[method] = {}
196
- self.unlocalized_methods.reject { |i| not i =~ matcher }.each do |i|
195
+ unlocalized_methods.select { |i| i =~ matcher }.each do |i|
197
196
  @unlocalized_setters[method][i.to_s.match(matcher)[1]] = i.to_s
198
197
  end
199
198
  end
@@ -1,21 +1,21 @@
1
- =begin
2
- Translation string for i18n support.
3
-
4
- Copyright (C) 2008 Andrey “A.I.” Sitnik <andrey@sitnik.ru>
5
-
6
- This program is free software: you can redistribute it and/or modify
7
- it under the terms of the GNU Lesser General Public License as published by
8
- the Free Software Foundation, either version 3 of the License, or
9
- (at your option) any later version.
10
-
11
- This program is distributed in the hope that it will be useful,
12
- but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- GNU Lesser General Public License for more details.
15
-
16
- You should have received a copy of the GNU Lesser General Public License
17
- along with this program. If not, see <http://www.gnu.org/licenses/>.
18
- =end
1
+ # frozen_string_literal: true
2
+
3
+ # Translation string for i18n support.
4
+ #
5
+ # Copyright (C) 2008 Andrey “A.I.” Sitnik <andrey@sitnik.ru>
6
+ #
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser General Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser General Public License
18
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
19
 
20
20
  module R18n
21
21
  # String, which is translated to some locale and loading from Translation.
@@ -36,7 +36,7 @@ module R18n
36
36
  end
37
37
 
38
38
  # Return self for translated string.
39
- def |(default)
39
+ def |(_other)
40
40
  self
41
41
  end
42
42
 
@@ -60,18 +60,18 @@ module R18n
60
60
  end
61
61
 
62
62
  # Define `as_json` for ActiveSupport compatibility.
63
- def as_json(options = nil)
63
+ def as_json(_options = nil)
64
64
  to_str
65
65
  end
66
66
 
67
67
  # Override marshal_dump to avoid Marshalizing filter procs
68
- def _dump(limit)
69
- [@locale.code, @path, to_str].join(":")
68
+ def _dump(_limit)
69
+ [@locale.code, @path, to_str].join(':')
70
70
  end
71
71
 
72
72
  # Load object from Marshalizing.
73
73
  def self._load(str)
74
- arr = str.split(":", 3)
74
+ arr = str.split(':', 3)
75
75
  new arr[2], R18n.locale(arr[0]), arr[1]
76
76
  end
77
77
 
@@ -83,7 +83,7 @@ module R18n
83
83
  end
84
84
 
85
85
  # Return untranslated, when user try to go deeper in translation.
86
- def method_missing(name, *params)
86
+ def method_missing(name, *_params)
87
87
  get_untranslated(name.to_s)
88
88
  end
89
89
  end
@@ -1,23 +1,21 @@
1
- =begin
2
- Translation to i18n support.
1
+ # frozen_string_literal: true
3
2
 
4
- Copyright (C) 2008 Andrey “A.I.” Sitnik <andrey@sitnik.ru>
5
-
6
- This program is free software: you can redistribute it and/or modify
7
- it under the terms of the GNU Lesser General Public License as published by
8
- the Free Software Foundation, either version 3 of the License, or
9
- (at your option) any later version.
10
-
11
- This program is distributed in the hope that it will be useful,
12
- but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- GNU Lesser General Public License for more details.
15
-
16
- You should have received a copy of the GNU Lesser General Public License
17
- along with this program. If not, see <http://www.gnu.org/licenses/>.
18
- =end
19
-
20
- require 'pathname'
3
+ # Translation to i18n support.
4
+ #
5
+ # Copyright (C) 2008 Andrey “A.I.” Sitnik <andrey@sitnik.ru>
6
+ #
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser General Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser General Public License
18
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
21
19
 
22
20
  module R18n
23
21
  # Struct to containt translation with some type for filter.
@@ -83,13 +81,15 @@ module R18n
83
81
  # Add another hash with +translations+ for some +locale+. Current data is
84
82
  # more priority, that new one in +translations+.
85
83
  def merge!(translations, locale)
86
- (translations || { }).each_pair do |name, value|
87
- if not @data.has_key? name
84
+ (translations || {}).each_pair do |name, value|
85
+ if !@data.key?(name)
88
86
  path = @path.empty? ? name : "#{@path}.#{name}"
89
87
  case value
90
88
  when Hash
91
- value = Translation.new(@locale, path,
92
- locale: locale, translations: value, filters: @filters)
89
+ value = Translation.new(
90
+ @locale, path,
91
+ locale: locale, translations: value, filters: @filters
92
+ )
93
93
  when String
94
94
  c = { locale: locale, path: path }
95
95
  v = @filters.process_string(:passive, value, c, [])
@@ -98,11 +98,11 @@ module R18n
98
98
  value.locale = locale
99
99
  value.path = path
100
100
  unless @filters.passive(value.type).empty?
101
- value = @filters.process_typed(:passive, value, { })
101
+ value = @filters.process_typed(:passive, value, {})
102
102
  end
103
103
  end
104
104
  @data[name] = value
105
- elsif @data[name].is_a? Translation and value.is_a? Hash
105
+ elsif @data[name].is_a?(Translation) && value.is_a?(Hash)
106
106
  @data[name].merge! value, locale
107
107
  end
108
108
  end
@@ -110,8 +110,9 @@ module R18n
110
110
 
111
111
  # Use untranslated filter to print path.
112
112
  def to_s
113
- @filters.process(:all, Untranslated, @path, @locale, @path,
114
- [@path, '', @path])
113
+ @filters.process(
114
+ :all, Untranslated, @path, @locale, @path, [@path, '', @path]
115
+ )
115
116
  end
116
117
 
117
118
  # Override inspect to easy debug.
@@ -136,8 +137,8 @@ module R18n
136
137
  end
137
138
 
138
139
  # Return +default+.
139
- def |(default)
140
- default
140
+ def |(other)
141
+ other
141
142
  end
142
143
 
143
144
  # Return translation with special +name+.
@@ -146,7 +147,7 @@ module R18n
146
147
  # <tt>%2</tt>, etc in translations file and set values in next +params+.
147
148
  def [](name, *params)
148
149
  unless [String, Integer, TrueClass, FalseClass]
149
- .any? { |klass| name.is_a?(klass) }
150
+ .any? { |klass| name.is_a?(klass) }
150
151
  name = name.to_s
151
152
  end
152
153
  value = @data[name]
@@ -1,21 +1,21 @@
1
- =begin
2
- Locale withou information file to i18n support.
3
-
4
- Copyright (C) 2008 Andrey “A.I.” Sitnik <andrey@sitnik.ru>
5
-
6
- This program is free software: you can redistribute it and/or modify
7
- it under the terms of the GNU Lesser General Public License as published by
8
- the Free Software Foundation, either version 3 of the License, or
9
- (at your option) any later version.
10
-
11
- This program is distributed in the hope that it will be useful,
12
- but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- GNU Lesser General Public License for more details.
15
-
16
- You should have received a copy of the GNU Lesser General Public License
17
- along with this program. If not, see <http://www.gnu.org/licenses/>.
18
- =end
1
+ # frozen_string_literal: true
2
+
3
+ # Locale withou information file to i18n support.
4
+ #
5
+ # Copyright (C) 2008 Andrey “A.I.” Sitnik <andrey@sitnik.ru>
6
+ #
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser General Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser General Public License
18
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
19
 
20
20
  module R18n
21
21
  # Locale without information file. Contain only it code, empty title and data
@@ -26,7 +26,7 @@ module R18n
26
26
 
27
27
  # Create object for unsupported locale with +code+ and load other locale
28
28
  # data from +base+ locale.
29
- def initialize(code, base = nil)
29
+ def initialize(code, _base = nil)
30
30
  @code = code
31
31
  @base = Locale.load(I18n.default) if @code != I18n.default
32
32
  end
@@ -42,9 +42,7 @@ module R18n
42
42
  end
43
43
 
44
44
  # Locale RFC 3066 code.
45
- def code
46
- @code
47
- end
45
+ attr_reader :code
48
46
 
49
47
  # Locale code as title.
50
48
  def title
@@ -52,8 +50,8 @@ module R18n
52
50
  end
53
51
 
54
52
  # Is another locale has same code.
55
- def ==(locale)
56
- @code.downcase == locale.code.downcase
53
+ def ==(other)
54
+ @code.casecmp(other.code).zero?
57
55
  end
58
56
 
59
57
  # Proxy to default locale object.
@@ -1,21 +1,21 @@
1
- =begin
2
- Untranslation string for i18n support.
3
-
4
- Copyright (C) 2008 Andrey “A.I.” Sitnik <andrey@sitnik.ru>
5
-
6
- This program is free software: you can redistribute it and/or modify
7
- it under the terms of the GNU Lesser General Public License as published by
8
- the Free Software Foundation, either version 3 of the License, or
9
- (at your option) any later version.
10
-
11
- This program is distributed in the hope that it will be useful,
12
- but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- GNU Lesser General Public License for more details.
15
-
16
- You should have received a copy of the GNU Lesser General Public License
17
- along with this program. If not, see <http://www.gnu.org/licenses/>.
18
- =end
1
+ # frozen_string_literal: true
2
+
3
+ # Untranslation string for i18n support.
4
+ #
5
+ # Copyright (C) 2008 Andrey “A.I.” Sitnik <andrey@sitnik.ru>
6
+ #
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser General Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser General Public License
18
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
19
 
20
20
  module R18n
21
21
  # Return if translation isn’t exists. Unlike nil, it didn’t raise error when
@@ -63,20 +63,20 @@ module R18n
63
63
  end
64
64
 
65
65
  # Override marshal_dump to avoid Marshalizing filter procs
66
- def _dump(limit)
67
- [@locale.code, @translated_path, @untranslated_path].join(":")
66
+ def _dump(_limit)
67
+ [@locale.code, @translated_path, @untranslated_path].join(':')
68
68
  end
69
69
 
70
70
  # Load object from Marshalizing.
71
71
  def self._load(str)
72
- arr = str.split(":", 3)
72
+ arr = str.split(':', 3)
73
73
  new arr[1], arr[2], R18n.locale(arr[0]), GlobalFilterList.instance
74
74
  end
75
75
 
76
- def method_missing(name, *params)
76
+ def method_missing(name, *_params)
77
77
  # It is need to fix some hack in specs
78
78
  if name == :to_ary
79
- raise NoMethodError, "undefined method `to_ary' for #{to_s}"
79
+ raise NoMethodError, "undefined method `to_ary' for #{self}"
80
80
  end
81
81
 
82
82
  self[name]
@@ -87,23 +87,25 @@ module R18n
87
87
  @locale, @filters)
88
88
  end
89
89
 
90
- def |(default)
91
- default
90
+ def |(other)
91
+ other
92
92
  end
93
93
 
94
94
  def to_s
95
- @filters.process(:all, Untranslated, path, @locale, path,
96
- [@translated_path, @untranslated_path, path])
95
+ @filters.process(
96
+ :all, Untranslated, path, @locale, path,
97
+ [@translated_path, @untranslated_path, path]
98
+ )
97
99
  end
98
100
 
99
- alias :to_str :to_s
101
+ alias to_str to_s
100
102
 
101
103
  # Is another locale has same code.
102
- def ==(untrsl)
103
- return false unless untrsl.is_a? Untranslated
104
- return false unless locale == untrsl.locale
105
- return false unless translated_path == untrsl.translated_path
106
- return false unless untranslated_path == untrsl.untranslated_path
104
+ def ==(other)
105
+ return false unless other.is_a? Untranslated
106
+ return false unless locale == other.locale
107
+ return false unless translated_path == other.translated_path
108
+ return false unless untranslated_path == other.untranslated_path
107
109
  true
108
110
  end
109
111
  end