i18n_generators 2.2.0 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bec76578061eb5cf855f789e0f400c7164c0fcfedcaf9acaa2f9a9bdbb0f3ffa
4
- data.tar.gz: 957b013ff0aeb7d681a71932286b748a6b2faa3a1d539a045c3d64f7a714ab7c
3
+ metadata.gz: '097f1c212396f5d6839bdc1ddc42aa36e27ce3927e223fa177c141cbd39550d7'
4
+ data.tar.gz: 65f71ed176c40b4f8a2322268d0130d26a2beb609b9ef531ee0b9d8165563f69
5
5
  SHA512:
6
- metadata.gz: ecb5c4b87fab4807556f18d13e1e164e31673bf2be8b40caa49ed798bd5c96f14a154ba9ff886b09e8cafda4077a290cd31574afe8022229979dba4588867173
7
- data.tar.gz: 69f968747c9c95a606506850e184a5115aee48cf07aff61f5dda0eeeafd433bd86b76282735dff902d938a2d7a7bff6aa70b60ef3610fde902d8976e8d040cf2
6
+ metadata.gz: 33ab1f428aeea79be272e64e42be27d77390f89ac0c5951c632f08fb2f4bb6a2c97d9422e02ee6e4110eb2fc820a11bf905fd0df187c2867c6fd143bce5169a8
7
+ data.tar.gz: 99f773eda2878d9d65623d28a132154b411a2e967f469dae38dd04e1dfc70f44a0a517b91690f9f1c96a7182707e67fcc7b2c5f3e572434a35347037f238b1cb
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # i18n_generators
2
2
 
3
3
  A Rails plugin that generates the I18n locale files with automatic
4
- translation. Supporting Rails 5.1, 5.0, 4.2.x, 4.1.x, 4.0.x, 3.2.x, 3.1.x, 3.0.x,
4
+ translation. Supporting Rails 6.0, 5.2.x, 5.1.x, 5.0.x, 4.2.x, 4.1.x, 4.0.x, 3.2.x, 3.1.x, 3.0.x,
5
5
  2.3.x, and 2.2.x.
6
6
 
7
7
  Here's an example of generating a translation file (the example model is taken
@@ -57,8 +57,8 @@ Executes 1 and 2 at once.
57
57
 
58
58
  ## Supported versions
59
59
 
60
- * Ruby 2.3, 2.2.x, 2.1.x, 2.0.0, 1.9.x, 1.8.7
61
- * Ruby on Rails 5.1, 5.0, 4.2, 4.1, 4.0, 3.2, 3.1, 3.0
60
+ * Ruby 2.7, 2.6.x, 2.5.x, 2.4.x, 2.3.x, 2.2.x, 2.1.x, 2.0.0, 1.9.x, 1.8.7
61
+ * Ruby on Rails 6.0, 5.2, 5.1, 5.0, 4.2, 4.1, 4.0, 3.2, 3.1, 3.0
62
62
  * Ruby on Rails 2.3, 2.2 (supported by i18n_generators < 1.2)
63
63
 
64
64
 
@@ -12,8 +12,6 @@ Gem::Specification.new do |s|
12
12
  s.summary = 'A Rails generator that generates Rails I18n locale files with automatic translation for almost every known locale.'
13
13
  s.description = 'A Rails generator that generates Rails I18n locale files with automatic translation for almost every known locale.'
14
14
 
15
- s.rubyforge_project = 'i18n_generators'
16
-
17
15
  s.files = `git ls-files`.split("\n")
18
16
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
17
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
@@ -20,7 +20,7 @@ class I18nLocaleGenerator < Rails::Generators::NamedBase
20
20
  end
21
21
 
22
22
  def add_locale_config(config_contents)
23
- new_line = " config.i18n.default_locale = :#{locale_name}"
23
+ new_line = " config.i18n.default_locale = #{locale_name.to_sym.inspect.tr('"', '\'')}"
24
24
  if config_contents =~ /\n *config\.i18n\.default_locale *=/
25
25
  config_contents.sub(/ *config\.i18n\.default_locale *=.*/, new_line)
26
26
  elsif config_contents =~ /\n *#? *config\.i18n\.default_locale *=/
@@ -43,6 +43,6 @@ class I18nLocaleGenerator < Rails::Generators::NamedBase
43
43
  end
44
44
 
45
45
  def locale_name
46
- @_locale_name ||= file_name.gsub('_', '-').split('-').each.with_index.map {|s, i| i == 0 ? s : s.upcase}.join('-')
46
+ @_locale_name ||= file_name.tr('_', '-').split('-').each.with_index.map {|s, i| i == 0 ? s : s.upcase}.join('-')
47
47
  end
48
48
  end
@@ -10,7 +10,12 @@ class I18nTranslationGenerator < Rails::Generators::NamedBase
10
10
  end
11
11
  log "translating models to #{locale_name}..."
12
12
  I18n.locale = locale_name
13
- Rails.application.eager_load!
13
+
14
+ if Rails.try(:autoloaders).try(:zeitwerk_enabled?)
15
+ Rails.application.send :eager_load_with_dependencies!
16
+ else
17
+ Rails.application.eager_load!
18
+ end
14
19
 
15
20
  # activerecord:models comes first
16
21
  model_names_translations = order_hash translate_all(model_names_keys)
@@ -102,7 +107,7 @@ class I18nTranslationGenerator < Rails::Generators::NamedBase
102
107
  end
103
108
 
104
109
  def locale_name
105
- @_locale_name ||= file_name.gsub('_', '-').split('-').each.with_index.map {|s, i| i == 0 ? s : s.upcase}.join('-')
110
+ @_locale_name ||= file_name.tr('_', '-').split('-').each.with_index.map {|s, i| i == 0 ? s : s.upcase}.join('-')
106
111
  end
107
112
 
108
113
  def include_timestamps?
@@ -1,3 +1,3 @@
1
1
  module I18nGenerators
2
- VERSION = '2.2.0'
2
+ VERSION = '2.2.1'
3
3
  end
@@ -2,13 +2,14 @@ require 'test_helper'
2
2
  require 'generators/i18n_locale/i18n_locale_generator'
3
3
 
4
4
  class I18nLocaleGeneratorTest < Test::Unit::TestCase
5
- setup do
6
- @generator = I18nLocaleGenerator.new(['ja'])
7
- end
5
+ sub_test_case 'ja locale' do
6
+ setup do
7
+ @generator = I18nLocaleGenerator.new(['ja'])
8
+ end
8
9
 
9
- sub_test_case 'add_locale_config' do
10
- test 'when i18n.default_locale is configured in environment.rb' do
11
- config = <<-CONFIG
10
+ sub_test_case 'add_locale_config' do
11
+ test 'when i18n.default_locale is configured in environment.rb' do
12
+ config = <<-CONFIG
12
13
  module Tes
13
14
  class Application < Rails::Application
14
15
  config.i18n.default_locale = :de
@@ -16,17 +17,17 @@ module Tes
16
17
  end
17
18
  CONFIG
18
19
 
19
- assert_equal <<-RESULT, @generator.send(:add_locale_config, config)
20
+ assert_equal <<-RESULT, @generator.send(:add_locale_config, config)
20
21
  module Tes
21
22
  class Application < Rails::Application
22
23
  config.i18n.default_locale = :ja
23
24
  end
24
25
  end
25
26
  RESULT
26
- end
27
+ end
27
28
 
28
- test 'when i18n.default_locale config is commented in environment.rb' do
29
- config = <<-CONFIG
29
+ test 'when i18n.default_locale config is commented in environment.rb' do
30
+ config = <<-CONFIG
30
31
  module Tes
31
32
  class Application < Rails::Application
32
33
  # config.i18n.default_locale = :de
@@ -34,17 +35,17 @@ module Tes
34
35
  end
35
36
  CONFIG
36
37
 
37
- assert_equal <<-RESULT, @generator.send(:add_locale_config, config)
38
+ assert_equal <<-RESULT, @generator.send(:add_locale_config, config)
38
39
  module Tes
39
40
  class Application < Rails::Application
40
41
  config.i18n.default_locale = :ja
41
42
  end
42
43
  end
43
44
  RESULT
44
- end
45
+ end
45
46
 
46
- test 'when i18n.default_locale is not written in environment.rb' do
47
- config = <<-CONFIG
47
+ test 'when i18n.default_locale is not written in environment.rb' do
48
+ config = <<-CONFIG
48
49
  module Tes
49
50
  class Application < Rails::Application
50
51
  something goes here.
@@ -53,7 +54,7 @@ module Tes
53
54
  end
54
55
  CONFIG
55
56
 
56
- assert_equal <<-RESULT, @generator.send(:add_locale_config, config)
57
+ assert_equal <<-RESULT, @generator.send(:add_locale_config, config)
57
58
  module Tes
58
59
  class Application < Rails::Application
59
60
  config.i18n.default_locale = :ja
@@ -62,6 +63,72 @@ module Tes
62
63
  end
63
64
  end
64
65
  RESULT
66
+ end
67
+ end
68
+ end
69
+
70
+ sub_test_case 'zh-CN locale' do
71
+ setup do
72
+ @generator = I18nLocaleGenerator.new(['zh-CN'])
73
+ end
74
+
75
+ sub_test_case 'add_locale_config' do
76
+ test 'when i18n.default_locale is configured in environment.rb' do
77
+ config = <<-CONFIG
78
+ module Tes
79
+ class Application < Rails::Application
80
+ config.i18n.default_locale = :de
81
+ end
82
+ end
83
+ CONFIG
84
+
85
+ assert_equal <<-RESULT, @generator.send(:add_locale_config, config)
86
+ module Tes
87
+ class Application < Rails::Application
88
+ config.i18n.default_locale = :'zh-CN'
89
+ end
90
+ end
91
+ RESULT
92
+ end
93
+
94
+ test 'when i18n.default_locale config is commented in environment.rb' do
95
+ config = <<-CONFIG
96
+ module Tes
97
+ class Application < Rails::Application
98
+ # config.i18n.default_locale = :de
99
+ end
100
+ end
101
+ CONFIG
102
+
103
+ assert_equal <<-RESULT, @generator.send(:add_locale_config, config)
104
+ module Tes
105
+ class Application < Rails::Application
106
+ config.i18n.default_locale = :'zh-CN'
107
+ end
108
+ end
109
+ RESULT
110
+ end
111
+
112
+ test 'when i18n.default_locale is not written in environment.rb' do
113
+ config = <<-CONFIG
114
+ module Tes
115
+ class Application < Rails::Application
116
+ something goes here.
117
+ bla bla bla...
118
+ end
119
+ end
120
+ CONFIG
121
+
122
+ assert_equal <<-RESULT, @generator.send(:add_locale_config, config)
123
+ module Tes
124
+ class Application < Rails::Application
125
+ config.i18n.default_locale = :'zh-CN'
126
+ something goes here.
127
+ bla bla bla...
128
+ end
129
+ end
130
+ RESULT
131
+ end
65
132
  end
66
133
  end
67
134
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i18n_generators
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Akira Matsuda
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-15 00:00:00.000000000 Z
11
+ date: 2019-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -132,8 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
132
132
  - !ruby/object:Gem::Version
133
133
  version: '0'
134
134
  requirements: []
135
- rubyforge_project: i18n_generators
136
- rubygems_version: 2.7.7
135
+ rubygems_version: 3.0.3
137
136
  signing_key:
138
137
  specification_version: 4
139
138
  summary: A Rails generator that generates Rails I18n locale files with automatic translation