amatsuda-i18n_generators 0.4.0 → 0.4.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.
- data/History.txt +68 -0
- data/README.rdoc +13 -5
- data/Rakefile +7 -7
- data/generators/i18n/i18n_generator.rb +3 -0
- data/generators/i18n_translation/lib/erb_executer.rb +4 -1
- data/spec/cldr_spec.rb +2 -0
- data/spec/i18n_locale_command_spec.rb +1 -0
- data/spec/i18n_translation_command_spec.rb +1 -0
- data/spec/translator_spec.rb +2 -0
- data/spec/yaml_spec.rb +21 -1
- metadata +3 -2
data/History.txt
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
== 0.4.1
|
2
|
+
|
3
|
+
* bugfixes:
|
4
|
+
* i18n_translation abnormally ends when loading a view containing "-%>" (thanks to babie-san!)
|
5
|
+
|
6
|
+
== 0.4.0
|
7
|
+
|
8
|
+
* major enhancements:
|
9
|
+
* translation generator now preserves any existing extra lines in the YAML file (thanks to Iain Hecker-san!)
|
10
|
+
|
11
|
+
== 0.3.4
|
12
|
+
|
13
|
+
* enhancements:
|
14
|
+
* Reduce unnecessary request to CLDR site
|
15
|
+
|
16
|
+
== 0.3.3
|
17
|
+
|
18
|
+
* bugfixes:
|
19
|
+
* Did not work on Ruby 1.8.6 (thanks to akm-san!)
|
20
|
+
|
21
|
+
== 0.3.2
|
22
|
+
|
23
|
+
* bugfixes:
|
24
|
+
* Trim mode in ERB didn't work on some platforms (thanks to valda-san!)
|
25
|
+
|
26
|
+
== 0.3.1
|
27
|
+
|
28
|
+
* enhancements:
|
29
|
+
* Translate all keys simultaneously using thread
|
30
|
+
* Translations with :scope is going to be yamlized with proper hierarchy
|
31
|
+
|
32
|
+
== 0.3.0
|
33
|
+
|
34
|
+
* major enhancements:
|
35
|
+
* Renamed the generators
|
36
|
+
i18n_locales -> i18n_locale (i18n --locale)
|
37
|
+
i18n_models -> i18n_translation (i18n --translation)
|
38
|
+
* Handle all translate keys which appear in view files (thanks to PanosJee-san!)
|
39
|
+
|
40
|
+
== 0.2.0
|
41
|
+
|
42
|
+
* major enhancements:
|
43
|
+
* Implemented i18n_scaffold generator (thanks to Iain Hecker-san!)
|
44
|
+
|
45
|
+
* enhancements:
|
46
|
+
* i18n_models generator can now deal with non AR classes which has content_columns (thanks to Iain Hecker-san!)
|
47
|
+
|
48
|
+
== 0.1.0
|
49
|
+
|
50
|
+
* major enhancements:
|
51
|
+
* Fetch locale YAML file from rails-i18n project repository first
|
52
|
+
|
53
|
+
* bugfixes:
|
54
|
+
* Could not recognize model names with multipie words (thanks to makoto-san!)
|
55
|
+
|
56
|
+
== 0.0.8
|
57
|
+
|
58
|
+
* major enhancements:
|
59
|
+
* Lots of changes for this commit by DHH http://github.com/rails/rails/commit/d9b92ee11b33fed5c7a94a91415fa846705f7dd3
|
60
|
+
|
61
|
+
== 0.0.4
|
62
|
+
|
63
|
+
* Gemified on GitHub
|
64
|
+
|
65
|
+
== 0.0.1
|
66
|
+
|
67
|
+
* Birthday!
|
68
|
+
|
data/README.rdoc
CHANGED
@@ -39,9 +39,15 @@ This will generate following locale file.
|
|
39
39
|
The generator copies the en.yml file (bundled inside Rails framework) into config/locales directory, and one-to-one localizes/translates each attribute value into the specified locale/language.
|
40
40
|
Then the generater sets the application default locale to the specified locale.
|
41
41
|
|
42
|
-
|
42
|
+
For example,
|
43
43
|
|
44
|
-
|
44
|
+
% ./script/generate i18n_locale zh
|
45
|
+
|
46
|
+
will generate following locale files.
|
47
|
+
|
48
|
+
config/locales/active_support_zh.yml
|
49
|
+
config/locales/active_record_zh.yml
|
50
|
+
config/locales/action_view_zh.yml
|
45
51
|
|
46
52
|
=== 3. Generate Translation YAML File For All Models/Attributes and views/**/*.erb
|
47
53
|
|
@@ -58,7 +64,7 @@ This will generate following YAML file.
|
|
58
64
|
The generator scans your app/models directory, and generates a YAML file with all the AR model names and attributes so that you don't have to write the YAML skeleton manually or by copy/paste.
|
59
65
|
In addition, the generator scans all the *.erb files in your app/views/** directory, and picks all the keys for I18n.translate, then adds them to the YAML file.
|
60
66
|
In addition, the generator tries to translate each of them into the specified language.
|
61
|
-
The generator doesn't overwrite the existing value so that you can rerun the generator again and again just like Annotate Model
|
67
|
+
The generator doesn't overwrite the existing value so that you can rerun the generator again and again just like Annotate Model command.
|
62
68
|
|
63
69
|
=== 4. Generate All
|
64
70
|
|
@@ -78,7 +84,9 @@ Executes 2 and 3 at once.
|
|
78
84
|
|
79
85
|
* As a gem
|
80
86
|
|
81
|
-
% sudo gem
|
87
|
+
% sudo gem source http://gems.github.com
|
88
|
+
|
89
|
+
% sudo gem install amatsuda-i18n_generators
|
82
90
|
|
83
91
|
* As a Rails plugin
|
84
92
|
|
@@ -87,7 +95,7 @@ Executes 2 and 3 at once.
|
|
87
95
|
|
88
96
|
== CAUTION
|
89
97
|
|
90
|
-
Current version of this plugin is very very very
|
98
|
+
Current version of this plugin is very very very roughly implemented just for experiment.
|
91
99
|
Every time you execute the generate command, the plugin connects to the Unicode CLDR website and scrapes the huge amount of its contents.
|
92
100
|
Please be careful not to harm your network environment and CLDR website by running this plugin too many times.
|
93
101
|
|
data/Rakefile
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
require 'rake'
|
2
2
|
require 'rake/testtask'
|
3
3
|
require 'rake/rdoctask'
|
4
|
+
require 'spec/rake/spectask'
|
4
5
|
|
5
|
-
desc 'Default: run
|
6
|
-
task :default => :
|
6
|
+
desc 'Default: run the specs.'
|
7
|
+
task :default => :spec
|
7
8
|
|
8
|
-
desc '
|
9
|
-
Rake::
|
10
|
-
t.
|
11
|
-
t.
|
12
|
-
t.verbose = true
|
9
|
+
desc 'Run the specs for i18n_generatoes.'
|
10
|
+
Spec::Rake::SpecTask.new(:spec) do |t|
|
11
|
+
t.spec_opts = ['--colour --format progress --loadby mtime --reverse']
|
12
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
13
13
|
end
|
14
14
|
|
15
15
|
desc 'Generate documentation for the i18n_generators plugin.'
|
@@ -35,10 +35,13 @@ class I18nGenerator < Rails::Generator::NamedBase
|
|
35
35
|
record do |m|
|
36
36
|
m.directory 'config/locales'
|
37
37
|
unless options[:generate_translation_only]
|
38
|
+
logger.debug 'updating environment.rb ...'
|
38
39
|
m.generate_configuration
|
39
40
|
if defined_in_rails_i18n_repository?
|
41
|
+
logger.debug "fetching #{locale_name}.yml from rails-i18n repository..."
|
40
42
|
m.fetch_from_rails_i18n_repository
|
41
43
|
else
|
44
|
+
logger.debug "generating #{locale_name} YAML files for Rails..."
|
42
45
|
m.active_support_yaml
|
43
46
|
m.active_record_yaml
|
44
47
|
m.action_view_yaml
|
@@ -15,7 +15,10 @@ module I18nTranslationGeneratorModule
|
|
15
15
|
def method_missing(method, *args, &block); nil; end
|
16
16
|
end
|
17
17
|
|
18
|
-
|
18
|
+
fname = '#{filename}'
|
19
|
+
erb = nil
|
20
|
+
File.open(fname) {|f| erb = ERB.new(f.read, nil, '-') }
|
21
|
+
erb.def_method(self, 'execute', fname)
|
19
22
|
end
|
20
23
|
EOS
|
21
24
|
m.const_get('Executer').new.execute { }
|
data/spec/cldr_spec.rb
CHANGED
data/spec/translator_spec.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
$KCODE = 'U'
|
2
2
|
|
3
|
+
require File.join(File.dirname(__FILE__), 'spec_helper')
|
3
4
|
require File.join(File.dirname(__FILE__), '../generators/i18n_translation/lib/translator')
|
4
5
|
include I18nTranslationGeneratorModule
|
5
6
|
|
@@ -12,6 +13,7 @@ describe Translator do
|
|
12
13
|
before do
|
13
14
|
res_200 = mock('res_200')
|
14
15
|
res_200.stub!(:read).and_return('{"responseData": {"translatedText":"こんにちは"}, "responseDetails": null, "responseStatus": 200}')
|
16
|
+
OpenURI.stub!(:open_uri).and_return(res_200)
|
15
17
|
end
|
16
18
|
|
17
19
|
it 'returns translated text' do
|
data/spec/yaml_spec.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'spec_helper')
|
1
2
|
require File.join(File.dirname(__FILE__), '/../generators/i18n/lib/yaml')
|
3
|
+
|
2
4
|
include I18nLocaleGeneratorModule
|
3
5
|
|
4
6
|
describe 'Yaml' do
|
@@ -32,7 +34,25 @@ describe 'Yaml' do
|
|
32
34
|
end
|
33
35
|
|
34
36
|
it 'should generate a path string on any node' do
|
35
|
-
@yaml['ja']['activerecord']['errors']['messages'].path.should == '/ja
|
37
|
+
@yaml['ja']['activerecord']['errors']['messages'].path.should == '/ja/activerecord/errors/messages'
|
38
|
+
end
|
39
|
+
|
40
|
+
describe '[] method' do
|
41
|
+
describe 'when a child with the specified key exists' do
|
42
|
+
it 'should return a child which has the specified key'
|
43
|
+
|
44
|
+
it 'should not modify the YAML contents'
|
45
|
+
end
|
46
|
+
|
47
|
+
describe 'when a child with the specified key exists' do
|
48
|
+
it 'should return a new node with the specified key'
|
49
|
+
|
50
|
+
it 'should append the created node under the current node'
|
51
|
+
|
52
|
+
it 'should append the created line to the YAML document'
|
53
|
+
|
54
|
+
it 'should increment the line number of the succeeding lines of the newly added line'
|
55
|
+
end
|
36
56
|
end
|
37
57
|
end
|
38
58
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: amatsuda-i18n_generators
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Akira Matsuda
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2009-01-21 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -30,6 +30,7 @@ extensions: []
|
|
30
30
|
extra_rdoc_files: []
|
31
31
|
|
32
32
|
files:
|
33
|
+
- History.txt
|
33
34
|
- MIT-LICENSE
|
34
35
|
- README.rdoc
|
35
36
|
- Rakefile
|