r18n-core 4.0.0 → 5.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog.md +398 -0
  3. data/README.md +23 -13
  4. data/lib/r18n-core.rb +10 -25
  5. data/lib/r18n-core/filter_list.rb +6 -3
  6. data/lib/r18n-core/filters.rb +21 -22
  7. data/lib/r18n-core/i18n.rb +9 -16
  8. data/lib/r18n-core/locale.rb +20 -21
  9. data/lib/r18n-core/locales/cy.rb +1 -1
  10. data/lib/r18n-core/locales/en-au.rb +1 -1
  11. data/lib/r18n-core/locales/en-gb.rb +1 -1
  12. data/lib/r18n-core/locales/en-us.rb +1 -1
  13. data/lib/r18n-core/locales/en.rb +2 -2
  14. data/lib/r18n-core/locales/es-cl.rb +1 -1
  15. data/lib/r18n-core/locales/es-us.rb +1 -1
  16. data/lib/r18n-core/locales/es.rb +2 -0
  17. data/lib/r18n-core/locales/fi.rb +2 -2
  18. data/lib/r18n-core/locales/fr.rb +3 -3
  19. data/lib/r18n-core/locales/it.rb +3 -3
  20. data/lib/r18n-core/locales/pt.rb +2 -0
  21. data/lib/r18n-core/locales/zh-cn.rb +1 -1
  22. data/lib/r18n-core/locales/zh-tw.rb +1 -1
  23. data/lib/r18n-core/locales/zh.rb +2 -0
  24. data/lib/r18n-core/translated.rb +4 -4
  25. data/lib/r18n-core/translated_string.rb +1 -6
  26. data/lib/r18n-core/translation.rb +1 -1
  27. data/lib/r18n-core/unsupported_locale.rb +2 -0
  28. data/lib/r18n-core/utils.rb +1 -1
  29. data/lib/r18n-core/version.rb +1 -1
  30. metadata +198 -89
  31. data/.rspec +0 -1
  32. data/Rakefile +0 -13
  33. data/r18n-core.gemspec +0 -29
  34. data/spec/filters_spec.rb +0 -327
  35. data/spec/i18n_spec.rb +0 -274
  36. data/spec/locale_spec.rb +0 -251
  37. data/spec/locales/af_spec.rb +0 -9
  38. data/spec/locales/cs_spec.rb +0 -23
  39. data/spec/locales/en-us_spec.rb +0 -28
  40. data/spec/locales/en_spec.rb +0 -13
  41. data/spec/locales/es-us_spec.rb +0 -11
  42. data/spec/locales/fa_spec.rb +0 -10
  43. data/spec/locales/fi_spec.rb +0 -9
  44. data/spec/locales/fr_spec.rb +0 -9
  45. data/spec/locales/hu_spec.rb +0 -19
  46. data/spec/locales/id_spec.rb +0 -23
  47. data/spec/locales/it_spec.rb +0 -10
  48. data/spec/locales/no_spec.rb +0 -9
  49. data/spec/locales/pl_spec.rb +0 -23
  50. data/spec/locales/ru_spec.rb +0 -23
  51. data/spec/locales/sk_spec.rb +0 -23
  52. data/spec/locales/th_spec.rb +0 -9
  53. data/spec/locales/vi_spec.rb +0 -9
  54. data/spec/r18n_spec.rb +0 -192
  55. data/spec/spec_helper.rb +0 -38
  56. data/spec/translated_spec.rb +0 -225
  57. data/spec/translation_spec.rb +0 -189
  58. data/spec/translations/extension/deep/en.yml +0 -1
  59. data/spec/translations/extension/en.yml +0 -2
  60. data/spec/translations/extension/notransl.yml +0 -1
  61. data/spec/translations/general/en.yml +0 -52
  62. data/spec/translations/general/nolocale.yml +0 -6
  63. data/spec/translations/general/ru.yml +0 -7
  64. data/spec/translations/two/en.yml +0 -2
  65. data/spec/translations/two/fr.yml +0 -0
  66. data/spec/translations/with_regions/en-US.yml +0 -0
  67. data/spec/translations/yaml/en-GB.yml +0 -1
  68. data/spec/translations/yaml/en-us.yml +0 -1
  69. data/spec/translations/yaml/en.yaml +0 -1
  70. data/spec/yaml_loader_spec.rb +0 -63
@@ -7,6 +7,8 @@ module R18n
7
7
  set(
8
8
  title: 'Español',
9
9
 
10
+ sublocales: %w[es-US es-CL],
11
+
10
12
  wday_names: %w[domingo lunes martes miércoles jueves viernes sábado],
11
13
  wday_abbrs: %w[dom lun mar mie jue vie sab],
12
14
 
@@ -31,8 +31,8 @@ module R18n
31
31
  number_group: ''
32
32
  )
33
33
 
34
- def format_time_full(time, *_params)
35
- format_time(format_date_full(time) + ' kello', time)
34
+ def format_time_full(time)
35
+ format_time "#{format_date_full(time)} kello", time
36
36
  end
37
37
  end
38
38
  end
@@ -26,10 +26,10 @@ module R18n
26
26
  number_group: ' '
27
27
  )
28
28
 
29
- def format_date_full(date, year = true, *_params)
30
- full = super(date, year)
29
+ def format_date_full(date, year: true, **_kwargs)
30
+ full = super(date, year: year)
31
31
  if full[0..1] == '1 '
32
- '1er' + full[1..-1]
32
+ "1er#{full[1..-1]}"
33
33
  else
34
34
  full
35
35
  end
@@ -24,10 +24,10 @@ module R18n
24
24
  number_group: ' '
25
25
  )
26
26
 
27
- def format_date_full(date, year = true, *_params)
28
- full = super(date, year)
27
+ def format_date_full(date, year: true, **_kwargs)
28
+ full = super(date, year: year)
29
29
  if full[0..1] == '1 '
30
- '1º' + full[1..-1]
30
+ "1º#{full[1..-1]}"
31
31
  else
32
32
  full
33
33
  end
@@ -7,6 +7,8 @@ module R18n
7
7
  set(
8
8
  title: 'Português',
9
9
 
10
+ sublocales: %w[pt-BR],
11
+
10
12
  wday_names: %w[
11
13
  domingo segunda-feira terça-feira quarta-feira quinta-feira
12
14
  sexta-feira sábado
@@ -8,7 +8,7 @@ module R18n
8
8
  class ZhCN < Zh
9
9
  set(
10
10
  title: '简体中文',
11
- sublocales: %w[zh en]
11
+ sublocales: %w[zh zh-TW en]
12
12
  )
13
13
  end
14
14
  end
@@ -8,7 +8,7 @@ module R18n
8
8
  class ZhTW < Zh
9
9
  set(
10
10
  title: '繁體中文',
11
- sublocales: %w[zh en],
11
+ sublocales: %w[zh zh-CN en],
12
12
 
13
13
  wday_names: %w[星期日 星期壹 星期二 星期三 星期四 星期五 星期六],
14
14
  wday_abbrs: %w[周日 周壹 周二 周三 周四 周五 周六],
@@ -7,6 +7,8 @@ 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
 
@@ -108,14 +108,14 @@ module R18n
108
108
  # Add proxy-method `name`. See `R18n::Translated` for description.
109
109
  # It's more useful to set options.
110
110
  #
111
- # translation :desciption, type: 'markdown'
111
+ # translation :description, type: 'markdown'
112
112
  def translation(name, options = {})
113
113
  if options[:methods]
114
114
  @unlocalized_getters[name] =
115
115
  options[:methods].map { |l, i| [l.to_s, i.to_s] }.to_h
116
116
  unless options[:no_write]
117
117
  @unlocalized_setters[name] =
118
- options[:methods].map { |l, i| [l.to_s, i.to_s + '='] }.to_h
118
+ options[:methods].map { |l, i| [l.to_s, "#{i}="] }.to_h
119
119
  end
120
120
  end
121
121
 
@@ -176,7 +176,7 @@ module R18n
176
176
  # didn't set map in `translation` option `methods`, it will be detect
177
177
  # automatically.
178
178
  def unlocalized_getters(method)
179
- matcher = Regexp.new('^' + Regexp.escape(method.to_s) + '_(\w+)$')
179
+ matcher = Regexp.new("^#{Regexp.escape(method.to_s)}_(\\w+)$")
180
180
  unless @unlocalized_getters.key? method
181
181
  @unlocalized_getters[method] = {}
182
182
  unlocalized_methods.select { |i| i =~ matcher }.each do |i|
@@ -190,7 +190,7 @@ module R18n
190
190
  # didn't set map in `translation` option `methods`, it will be detect
191
191
  # automatically.
192
192
  def unlocalized_setters(method)
193
- matcher = Regexp.new('^' + Regexp.escape(method.to_s) + '_(\w+)=$')
193
+ matcher = Regexp.new("^#{Regexp.escape(method.to_s)}_(\\w+)=$")
194
194
  unless @unlocalized_setters.key? method
195
195
  @unlocalized_setters[method] = {}
196
196
  unlocalized_methods.select { |i| i =~ matcher }.each do |i|
@@ -47,14 +47,9 @@ module R18n
47
47
  true
48
48
  end
49
49
 
50
- # Return true if `html_safe` method is defined, otherwise false.
51
- def html_safe?
52
- respond_to? :html_safe
53
- end
54
-
55
50
  # Override to_s to make string html safe if `html_safe` method is defined.
56
51
  def to_s
57
- if html_safe?
52
+ if respond_to?(:html_safe)
58
53
  super.html_safe
59
54
  else
60
55
  String.new(super)
@@ -168,7 +168,7 @@ module R18n
168
168
  # Return translation located at `keys`.
169
169
  # @see Hash#dig
170
170
  def dig(*keys)
171
- keys.reduce(self) { |result, key| result[key] }
171
+ keys.reduce(self, :[])
172
172
  end
173
173
 
174
174
  # I think we don't need in the Ruby core method,
@@ -62,6 +62,8 @@ module R18n
62
62
  end
63
63
 
64
64
  def respond_to_missing?(name, *args)
65
+ return super unless @base
66
+
65
67
  @base.send __method__, name, *args
66
68
  end
67
69
  end
@@ -17,8 +17,8 @@
17
17
  # You should have received a copy of the GNU Lesser General Public License
18
18
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
19
 
20
- # Common methods for another R18n code.
21
20
  module R18n
21
+ # Common methods for another R18n code.
22
22
  module Utils
23
23
  # Escape HTML entries (<, >, &). Copy from HAML helper.
24
24
  def self.escape_html(content)
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Version of R18n Core
4
4
  module R18n
5
- VERSION = '4.0.0' unless defined? R18n::VERSION
5
+ VERSION = '5.0.1'
6
6
  end
metadata CHANGED
@@ -1,32 +1,208 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: r18n-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 5.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrey Sitnik
8
- autorequire:
8
+ - Alexander Popov
9
+ autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2020-01-30 00:00:00.000000000 Z
12
- dependencies: []
12
+ date: 2021-03-03 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: activesupport
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: '5'
21
+ - - "<"
22
+ - !ruby/object:Gem::Version
23
+ version: '7'
24
+ type: :development
25
+ prerelease: false
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ version: '5'
31
+ - - "<"
32
+ - !ruby/object:Gem::Version
33
+ version: '7'
34
+ - !ruby/object:Gem::Dependency
35
+ name: kramdown
36
+ requirement: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.3'
41
+ type: :development
42
+ prerelease: false
43
+ version_requirements: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.3'
48
+ - !ruby/object:Gem::Dependency
49
+ name: pry-byebug
50
+ requirement: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.9'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.9'
62
+ - !ruby/object:Gem::Dependency
63
+ name: RedCloth
64
+ requirement: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '4.3'
69
+ type: :development
70
+ prerelease: false
71
+ version_requirements: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '4.3'
76
+ - !ruby/object:Gem::Dependency
77
+ name: gem_toys
78
+ requirement: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.7.1
83
+ type: :development
84
+ prerelease: false
85
+ version_requirements: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.7.1
90
+ - !ruby/object:Gem::Dependency
91
+ name: toys
92
+ requirement: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.11.0
97
+ type: :development
98
+ prerelease: false
99
+ version_requirements: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 0.11.0
104
+ - !ruby/object:Gem::Dependency
105
+ name: rubocop
106
+ requirement: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '1.6'
111
+ type: :development
112
+ prerelease: false
113
+ version_requirements: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '1.6'
118
+ - !ruby/object:Gem::Dependency
119
+ name: rubocop-performance
120
+ requirement: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '1.9'
125
+ type: :development
126
+ prerelease: false
127
+ version_requirements: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '1.9'
132
+ - !ruby/object:Gem::Dependency
133
+ name: rubocop-rake
134
+ requirement: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: 0.5.1
139
+ type: :development
140
+ prerelease: false
141
+ version_requirements: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: 0.5.1
146
+ - !ruby/object:Gem::Dependency
147
+ name: codecov
148
+ requirement: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: 0.5.0
153
+ type: :development
154
+ prerelease: false
155
+ version_requirements: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: 0.5.0
160
+ - !ruby/object:Gem::Dependency
161
+ name: rspec
162
+ requirement: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '3.10'
167
+ type: :development
168
+ prerelease: false
169
+ version_requirements: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: '3.10'
174
+ - !ruby/object:Gem::Dependency
175
+ name: simplecov
176
+ requirement: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: 0.21.0
181
+ type: :development
182
+ prerelease: false
183
+ version_requirements: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: 0.21.0
13
188
  description: |2
14
189
  R18n is a i18n tool to translate your Ruby application.
15
190
  It has nice Ruby-style syntax, filters, flexible locales, custom loaders,
16
191
  translation support for any classes, time and number localization, several
17
192
  user language support, agnostic core package with out-of-box support for
18
193
  Rails, Sinatra and desktop applications.
19
- email: andrey@sitnik.ru
194
+ email:
195
+ - andrey@sitnik.ru
196
+ - alex.wayfer@gmail.com
20
197
  executables: []
21
198
  extensions: []
22
199
  extra_rdoc_files:
23
200
  - README.md
24
201
  - LICENSE
25
202
  files:
26
- - ".rspec"
203
+ - ChangeLog.md
27
204
  - LICENSE
28
205
  - README.md
29
- - Rakefile
30
206
  - base/af.yml
31
207
  - base/az.yml
32
208
  - base/bg.yml
@@ -125,49 +301,16 @@ files:
125
301
  - lib/r18n-core/version.rb
126
302
  - lib/r18n-core/yaml_loader.rb
127
303
  - lib/r18n-core/yaml_methods.rb
128
- - r18n-core.gemspec
129
- - spec/filters_spec.rb
130
- - spec/i18n_spec.rb
131
- - spec/locale_spec.rb
132
- - spec/locales/af_spec.rb
133
- - spec/locales/cs_spec.rb
134
- - spec/locales/en-us_spec.rb
135
- - spec/locales/en_spec.rb
136
- - spec/locales/es-us_spec.rb
137
- - spec/locales/fa_spec.rb
138
- - spec/locales/fi_spec.rb
139
- - spec/locales/fr_spec.rb
140
- - spec/locales/hu_spec.rb
141
- - spec/locales/id_spec.rb
142
- - spec/locales/it_spec.rb
143
- - spec/locales/no_spec.rb
144
- - spec/locales/pl_spec.rb
145
- - spec/locales/ru_spec.rb
146
- - spec/locales/sk_spec.rb
147
- - spec/locales/th_spec.rb
148
- - spec/locales/vi_spec.rb
149
- - spec/r18n_spec.rb
150
- - spec/spec_helper.rb
151
- - spec/translated_spec.rb
152
- - spec/translation_spec.rb
153
- - spec/translations/extension/deep/en.yml
154
- - spec/translations/extension/en.yml
155
- - spec/translations/extension/notransl.yml
156
- - spec/translations/general/en.yml
157
- - spec/translations/general/nolocale.yml
158
- - spec/translations/general/ru.yml
159
- - spec/translations/two/en.yml
160
- - spec/translations/two/fr.yml
161
- - spec/translations/with_regions/en-US.yml
162
- - spec/translations/yaml/en-GB.yml
163
- - spec/translations/yaml/en-us.yml
164
- - spec/translations/yaml/en.yaml
165
- - spec/yaml_loader_spec.rb
166
- homepage: https://github.com/r18n/r18n
304
+ homepage: https://github.com/r18n/r18n-core
167
305
  licenses:
168
306
  - LGPL-3.0
169
- metadata: {}
170
- post_install_message:
307
+ metadata:
308
+ bug_tracker_uri: https://github.com/r18n/r18n-core/issues
309
+ changelog_uri: https://github.com/r18n/r18n-core/blob/5.0.1/ChangeLog.md
310
+ documentation_uri: http://www.rubydoc.info/gems/r18n-core/5.0.1
311
+ homepage_uri: https://github.com/r18n/r18n-core
312
+ source_code_uri: https://github.com/r18n/r18n-core
313
+ post_install_message:
171
314
  rdoc_options: []
172
315
  require_paths:
173
316
  - lib
@@ -175,52 +318,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
175
318
  requirements:
176
319
  - - ">="
177
320
  - !ruby/object:Gem::Version
178
- version: '0'
321
+ version: '2.5'
322
+ - - "<"
323
+ - !ruby/object:Gem::Version
324
+ version: '4'
179
325
  required_rubygems_version: !ruby/object:Gem::Requirement
180
326
  requirements:
181
327
  - - ">="
182
328
  - !ruby/object:Gem::Version
183
329
  version: '0'
184
330
  requirements: []
185
- rubygems_version: 3.1.2
186
- signing_key:
331
+ rubygems_version: 3.2.3
332
+ signing_key:
187
333
  specification_version: 4
188
334
  summary: I18n tool to translate your Ruby application.
189
- test_files:
190
- - spec/filters_spec.rb
191
- - spec/i18n_spec.rb
192
- - spec/locale_spec.rb
193
- - spec/locales/af_spec.rb
194
- - spec/locales/cs_spec.rb
195
- - spec/locales/en-us_spec.rb
196
- - spec/locales/en_spec.rb
197
- - spec/locales/es-us_spec.rb
198
- - spec/locales/fa_spec.rb
199
- - spec/locales/fi_spec.rb
200
- - spec/locales/fr_spec.rb
201
- - spec/locales/hu_spec.rb
202
- - spec/locales/id_spec.rb
203
- - spec/locales/it_spec.rb
204
- - spec/locales/no_spec.rb
205
- - spec/locales/pl_spec.rb
206
- - spec/locales/ru_spec.rb
207
- - spec/locales/sk_spec.rb
208
- - spec/locales/th_spec.rb
209
- - spec/locales/vi_spec.rb
210
- - spec/r18n_spec.rb
211
- - spec/spec_helper.rb
212
- - spec/translated_spec.rb
213
- - spec/translation_spec.rb
214
- - spec/translations/extension/deep/en.yml
215
- - spec/translations/extension/en.yml
216
- - spec/translations/extension/notransl.yml
217
- - spec/translations/general/en.yml
218
- - spec/translations/general/nolocale.yml
219
- - spec/translations/general/ru.yml
220
- - spec/translations/two/en.yml
221
- - spec/translations/two/fr.yml
222
- - spec/translations/with_regions/en-US.yml
223
- - spec/translations/yaml/en-GB.yml
224
- - spec/translations/yaml/en-us.yml
225
- - spec/translations/yaml/en.yaml
226
- - spec/yaml_loader_spec.rb
335
+ test_files: []