i18n_generators 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/Gemfile +3 -0
- data/History.txt +8 -0
- data/MIT-LICENSE +1 -1
- data/README.rdoc +3 -3
- data/Rakefile +2 -38
- data/i18n_generators.gemspec +17 -87
- data/lib/generators/i18n_locale/i18n_locale_generator.rb +1 -9
- data/lib/generators/i18n_translation/i18n_translation_generator.rb +8 -15
- data/lib/generators/i18n_translation/lib/yaml.rb +6 -2
- data/lib/i18n_generators/version.rb +3 -0
- metadata +17 -14
- data/VERSION +0 -1
data/.gitignore
ADDED
data/Gemfile
ADDED
data/History.txt
CHANGED
data/MIT-LICENSE
CHANGED
data/README.rdoc
CHANGED
@@ -15,7 +15,7 @@ This gem/plugin provides following generate commands.
|
|
15
15
|
% rails g i18n_locale ja (de-AT, pt-BR, etc.)
|
16
16
|
|
17
17
|
Downloads the .yml file for the specified locale from the official rails-i18n repository:
|
18
|
-
|
18
|
+
https://github.com/svenfuchs/rails-i18n/tree/master/rails/locale
|
19
19
|
|
20
20
|
Then the generater sets the application default locale to the specified locale.
|
21
21
|
|
@@ -56,11 +56,11 @@ Executes 1 and 2 at once.
|
|
56
56
|
|
57
57
|
* With Bundler
|
58
58
|
|
59
|
-
Add 'i18n_generators' to your Gemfile, then `bundle`.
|
59
|
+
Add 'i18n_generators' to your Gemfile, then `bundle`. Restricting the group to :development would be a good idea, since the generator would probably be used only in development mode.
|
60
60
|
|
61
61
|
* As a Rails plugin
|
62
62
|
|
63
63
|
% rails plugin install git://github.com/amatsuda/i18n_generators.git
|
64
64
|
|
65
65
|
|
66
|
-
Copyright (c) 2008 -
|
66
|
+
Copyright (c) 2008 - 2011 Akira Matsuda, released under the MIT license
|
data/Rakefile
CHANGED
@@ -1,38 +1,2 @@
|
|
1
|
-
require '
|
2
|
-
|
3
|
-
require 'rake/testtask'
|
4
|
-
require 'rake/rdoctask'
|
5
|
-
# require 'spec/rake/spectask'
|
6
|
-
|
7
|
-
desc 'Default: run the specs.'
|
8
|
-
task :default => :spec
|
9
|
-
|
10
|
-
# desc 'Run the specs for i18n_generators.'
|
11
|
-
# Spec::Rake::SpecTask.new(:spec) do |t|
|
12
|
-
# t.spec_opts = ['--colour --format progress --loadby mtime --reverse']
|
13
|
-
# t.spec_files = FileList['spec/**/*_spec.rb']
|
14
|
-
# end
|
15
|
-
|
16
|
-
desc 'Generate documentation for the i18n_generators plugin.'
|
17
|
-
Rake::RDocTask.new(:rdoc) do |rdoc|
|
18
|
-
rdoc.rdoc_dir = 'rdoc'
|
19
|
-
rdoc.title = 'I18nGenerators'
|
20
|
-
rdoc.options << '--line-numbers' << '--inline-source'
|
21
|
-
rdoc.rdoc_files.include('README.rdoc')
|
22
|
-
rdoc.rdoc_files.include('generators/**/*.rb')
|
23
|
-
end
|
24
|
-
|
25
|
-
begin
|
26
|
-
require 'jeweler'
|
27
|
-
Jeweler::Tasks.new do |gemspec|
|
28
|
-
gemspec.name = 'i18n_generators'
|
29
|
-
gemspec.summary = 'Generates I18n locale files for Rails 3 and Rails 2'
|
30
|
-
gemspec.description = 'A Rails generator plugin & gem that generates Rails I18n locale files for almost every known locale.'
|
31
|
-
gemspec.email = 'ronnie@dio.jp'
|
32
|
-
gemspec.homepage = 'http://github.com/amatsuda/i18n_generators/'
|
33
|
-
gemspec.authors = ['Akira Matsuda']
|
34
|
-
end
|
35
|
-
Jeweler::GemcutterTasks.new
|
36
|
-
rescue LoadError
|
37
|
-
puts 'Jeweler not available. Install it with: gem install jeweler'
|
38
|
-
end
|
1
|
+
require 'bundler'
|
2
|
+
Bundler::GemHelper.install_tasks
|
data/i18n_generators.gemspec
CHANGED
@@ -1,94 +1,24 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
3
|
+
require 'i18n_generators/version'
|
5
4
|
|
6
5
|
Gem::Specification.new do |s|
|
7
|
-
s.name
|
8
|
-
s.version
|
6
|
+
s.name = 'i18n_generators'
|
7
|
+
s.version = I18nGenerators::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ['Akira Matsuda']
|
10
|
+
s.email = ['ronnie@dio.jp']
|
11
|
+
s.homepage = 'https://github.com/amatsuda/i18n_generators'
|
12
|
+
s.summary = 'Generates I18n locale files for Rails 3 and Rails 2'
|
13
|
+
s.description = 'A Rails generator plugin & gem that generates Rails I18n locale files for almost every known locale.'
|
9
14
|
|
10
|
-
s.
|
11
|
-
s.authors = ["Akira Matsuda"]
|
12
|
-
s.date = %q{2010-11-29}
|
13
|
-
s.description = %q{A Rails generator plugin & gem that generates Rails I18n locale files for almost every known locale.}
|
14
|
-
s.email = %q{ronnie@dio.jp}
|
15
|
-
s.extra_rdoc_files = [
|
16
|
-
"README.rdoc"
|
17
|
-
]
|
18
|
-
s.files = [
|
19
|
-
"History.txt",
|
20
|
-
"MIT-LICENSE",
|
21
|
-
"README.rdoc",
|
22
|
-
"Rakefile",
|
23
|
-
"VERSION",
|
24
|
-
"generators/i18n/USAGE",
|
25
|
-
"generators/i18n/i18n_generator.rb",
|
26
|
-
"generators/i18n/lib/yaml.rb",
|
27
|
-
"generators/i18n/templates/base.yml",
|
28
|
-
"generators/i18n/templates/i18n_config.rb",
|
29
|
-
"generators/i18n/templates/translation.yml",
|
30
|
-
"generators/i18n_locale/USAGE",
|
31
|
-
"generators/i18n_locale/i18n_locale_command.rb",
|
32
|
-
"generators/i18n_locale/i18n_locale_generator.rb",
|
33
|
-
"generators/i18n_locale/lib/cldr.rb",
|
34
|
-
"generators/i18n_scaffold/i18n_scaffold_generator.rb",
|
35
|
-
"generators/i18n_scaffold/templates/controller.rb",
|
36
|
-
"generators/i18n_scaffold/templates/functional_test.rb",
|
37
|
-
"generators/i18n_scaffold/templates/helper.rb",
|
38
|
-
"generators/i18n_scaffold/templates/helper_test.rb",
|
39
|
-
"generators/i18n_scaffold/templates/layout.html.erb",
|
40
|
-
"generators/i18n_scaffold/templates/style.css",
|
41
|
-
"generators/i18n_scaffold/templates/view_edit.html.erb",
|
42
|
-
"generators/i18n_scaffold/templates/view_index.html.erb",
|
43
|
-
"generators/i18n_scaffold/templates/view_new.html.erb",
|
44
|
-
"generators/i18n_scaffold/templates/view_show.html.erb",
|
45
|
-
"generators/i18n_translation/USAGE",
|
46
|
-
"generators/i18n_translation/i18n_translation_command.rb",
|
47
|
-
"generators/i18n_translation/i18n_translation_generator.rb",
|
48
|
-
"generators/i18n_translation/lib/erb_executer.rb",
|
49
|
-
"generators/i18n_translation/lib/recording_backend.rb",
|
50
|
-
"generators/i18n_translation/lib/through_ryoku.rb",
|
51
|
-
"generators/i18n_translation/lib/translator.rb",
|
52
|
-
"i18n_generators.gemspec",
|
53
|
-
"lib/generators/i18n/USAGE",
|
54
|
-
"lib/generators/i18n/i18n_generator.rb",
|
55
|
-
"lib/generators/i18n_locale/USAGE",
|
56
|
-
"lib/generators/i18n_locale/i18n_locale_generator.rb",
|
57
|
-
"lib/generators/i18n_translation/USAGE",
|
58
|
-
"lib/generators/i18n_translation/i18n_translation_generator.rb",
|
59
|
-
"lib/generators/i18n_translation/lib/translator.rb",
|
60
|
-
"lib/generators/i18n_translation/lib/yaml.rb",
|
61
|
-
"lib/generators/i18n_translation/lib/yaml_waml.rb",
|
62
|
-
"spec/cldr_spec.rb",
|
63
|
-
"spec/data/cldr/ja.html",
|
64
|
-
"spec/data/yml/active_record/en-US.yml",
|
65
|
-
"spec/i18n_locale_command_spec.rb",
|
66
|
-
"spec/i18n_translation_command_spec.rb",
|
67
|
-
"spec/spec_helper.rb",
|
68
|
-
"spec/translator_spec.rb",
|
69
|
-
"spec/yaml_spec.rb"
|
70
|
-
]
|
71
|
-
s.homepage = %q{http://github.com/amatsuda/i18n_generators/}
|
72
|
-
s.require_paths = ["lib"]
|
73
|
-
s.rubygems_version = %q{1.3.7}
|
74
|
-
s.summary = %q{Generates I18n locale files for Rails 3 and Rails 2}
|
75
|
-
s.test_files = [
|
76
|
-
"spec/cldr_spec.rb",
|
77
|
-
"spec/i18n_locale_command_spec.rb",
|
78
|
-
"spec/i18n_translation_command_spec.rb",
|
79
|
-
"spec/spec_helper.rb",
|
80
|
-
"spec/translator_spec.rb",
|
81
|
-
"spec/yaml_spec.rb"
|
82
|
-
]
|
15
|
+
s.rubyforge_project = 'i18n_generators'
|
83
16
|
|
84
|
-
|
85
|
-
|
86
|
-
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ['lib']
|
87
21
|
|
88
|
-
|
89
|
-
|
90
|
-
end
|
91
|
-
else
|
92
|
-
end
|
22
|
+
s.extra_rdoc_files = ['README.rdoc']
|
23
|
+
s.licenses = ['MIT']
|
93
24
|
end
|
94
|
-
|
@@ -35,15 +35,7 @@ class I18nLocaleGenerator < Rails::Generators::NamedBase
|
|
35
35
|
def fetch_from_rails_i18n_repository
|
36
36
|
log "fetching #{locale_name}.yml from rails-i18n repository..."
|
37
37
|
begin
|
38
|
-
|
39
|
-
http = Net::HTTP.new uri.host, uri.port
|
40
|
-
http.use_ssl = true
|
41
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
42
|
-
req = Net::HTTP::Get.new uri.request_uri
|
43
|
-
res = http.request req
|
44
|
-
raise unless res.code == '200'
|
45
|
-
|
46
|
-
create_file "config/locales/#{locale_name}.yml", res.body
|
38
|
+
get "https://github.com/svenfuchs/rails-i18n/raw/master/rails/locale/#{locale_name}.yml", "config/locales/#{locale_name}.yml"
|
47
39
|
rescue
|
48
40
|
log "could not find #{locale_name}.yml on rails-i18n repository"
|
49
41
|
end
|
@@ -10,6 +10,7 @@ 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
|
|
14
15
|
keys = aggregate_keys
|
15
16
|
translations = translate_all(keys)
|
@@ -32,23 +33,21 @@ class I18nTranslationGenerator < Rails::Generators::NamedBase
|
|
32
33
|
|
33
34
|
private
|
34
35
|
def aggregate_keys
|
35
|
-
models =
|
36
|
-
|
37
|
-
m
|
38
|
-
|
39
|
-
|
40
|
-
m
|
41
|
-
rescue
|
36
|
+
models = ActiveRecord::Base.descendants.map do |m|
|
37
|
+
begin
|
38
|
+
m if m.table_exists? && m.respond_to?(:content_columns)
|
39
|
+
rescue => e
|
40
|
+
p e
|
42
41
|
next
|
43
42
|
end
|
44
43
|
end.compact
|
45
44
|
|
46
45
|
translation_keys = []
|
47
|
-
translation_keys += models.map {|m| "activerecord.models.#{m.
|
46
|
+
translation_keys += models.map {|m| "activerecord.models.#{m.model_name.underscore}"}
|
48
47
|
models.each do |model|
|
49
48
|
cols = model.content_columns + model.reflect_on_all_associations
|
50
49
|
cols.delete_if {|c| %w[created_at updated_at].include? c.name} unless include_timestamps?
|
51
|
-
translation_keys += cols.map {|c| "activerecord.attributes.#{model.
|
50
|
+
translation_keys += cols.map {|c| "activerecord.attributes.#{model.model_name.underscore}.#{c.name}"}
|
52
51
|
end
|
53
52
|
translation_keys
|
54
53
|
end
|
@@ -94,12 +93,6 @@ class I18nTranslationGenerator < Rails::Generators::NamedBase
|
|
94
93
|
!!@include_timestamps
|
95
94
|
end
|
96
95
|
|
97
|
-
def model_filenames
|
98
|
-
Dir.chdir("#{Rails.root}/app/models/") do
|
99
|
-
Dir["**/*.rb"].map {|m| m.sub(/\.rb$/, '')}
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
96
|
# iterate through all values
|
104
97
|
def each_value(parents, src, &block)
|
105
98
|
src.each do |k, v|
|
@@ -1,4 +1,8 @@
|
|
1
|
-
|
1
|
+
begin
|
2
|
+
require 'psych'
|
3
|
+
rescue LoadError
|
4
|
+
require File.join(File.dirname(__FILE__), 'yaml_waml')
|
5
|
+
end
|
2
6
|
|
3
7
|
module I27r
|
4
8
|
class Line
|
@@ -44,7 +48,7 @@ module I27r
|
|
44
48
|
|
45
49
|
private
|
46
50
|
def generate_text(indent)
|
47
|
-
@text = indent + @yaml.to_yaml.sub(
|
51
|
+
@text = indent + @yaml.to_yaml.sub(/--- ?\n/, '').chomp.rstrip
|
48
52
|
end
|
49
53
|
end
|
50
54
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: i18n_generators
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 17
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 3
|
10
|
+
version: 1.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Akira Matsuda
|
@@ -15,12 +15,12 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
19
|
-
default_executable:
|
18
|
+
date: 2011-06-24 00:00:00 Z
|
20
19
|
dependencies: []
|
21
20
|
|
22
21
|
description: A Rails generator plugin & gem that generates Rails I18n locale files for almost every known locale.
|
23
|
-
email:
|
22
|
+
email:
|
23
|
+
- ronnie@dio.jp
|
24
24
|
executables: []
|
25
25
|
|
26
26
|
extensions: []
|
@@ -28,11 +28,12 @@ extensions: []
|
|
28
28
|
extra_rdoc_files:
|
29
29
|
- README.rdoc
|
30
30
|
files:
|
31
|
+
- .gitignore
|
32
|
+
- Gemfile
|
31
33
|
- History.txt
|
32
34
|
- MIT-LICENSE
|
33
35
|
- README.rdoc
|
34
36
|
- Rakefile
|
35
|
-
- VERSION
|
36
37
|
- generators/i18n/USAGE
|
37
38
|
- generators/i18n/i18n_generator.rb
|
38
39
|
- generators/i18n/lib/yaml.rb
|
@@ -71,6 +72,7 @@ files:
|
|
71
72
|
- lib/generators/i18n_translation/lib/translator.rb
|
72
73
|
- lib/generators/i18n_translation/lib/yaml.rb
|
73
74
|
- lib/generators/i18n_translation/lib/yaml_waml.rb
|
75
|
+
- lib/i18n_generators/version.rb
|
74
76
|
- spec/cldr_spec.rb
|
75
77
|
- spec/data/cldr/ja.html
|
76
78
|
- spec/data/yml/active_record/en-US.yml
|
@@ -79,10 +81,9 @@ files:
|
|
79
81
|
- spec/spec_helper.rb
|
80
82
|
- spec/translator_spec.rb
|
81
83
|
- spec/yaml_spec.rb
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
84
|
+
homepage: https://github.com/amatsuda/i18n_generators
|
85
|
+
licenses:
|
86
|
+
- MIT
|
86
87
|
post_install_message:
|
87
88
|
rdoc_options: []
|
88
89
|
|
@@ -108,13 +109,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
109
|
version: "0"
|
109
110
|
requirements: []
|
110
111
|
|
111
|
-
rubyforge_project:
|
112
|
-
rubygems_version: 1.
|
112
|
+
rubyforge_project: i18n_generators
|
113
|
+
rubygems_version: 1.8.5
|
113
114
|
signing_key:
|
114
115
|
specification_version: 3
|
115
116
|
summary: Generates I18n locale files for Rails 3 and Rails 2
|
116
117
|
test_files:
|
117
118
|
- spec/cldr_spec.rb
|
119
|
+
- spec/data/cldr/ja.html
|
120
|
+
- spec/data/yml/active_record/en-US.yml
|
118
121
|
- spec/i18n_locale_command_spec.rb
|
119
122
|
- spec/i18n_translation_command_spec.rb
|
120
123
|
- spec/spec_helper.rb
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
1.0.2
|