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 ADDED
@@ -0,0 +1,2 @@
1
+ pkg
2
+ Gemfile.lock
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gemspec
data/History.txt CHANGED
@@ -1,3 +1,11 @@
1
+ == 1.0.3
2
+
3
+ * bugfixes:
4
+ * #4 Translation generator recursive loop in ruby 1.9 + MS-Windows (memarko)
5
+
6
+ * enhancements:
7
+ * Some Rails-3-ish cleanups
8
+
1
9
  == 1.0.2
2
10
 
3
11
  * bugfixes:
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2008 [name of plugin creator]
1
+ Copyright (c) 2008-2011 Akira Matsuda
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
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
- http://github.com/svenfuchs/rails-i18n/tree/master/rails/locale
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 - 2010 Akira Matsuda, released under the MIT license
66
+ Copyright (c) 2008 - 2011 Akira Matsuda, released under the MIT license
data/Rakefile CHANGED
@@ -1,38 +1,2 @@
1
- require 'rubygems'
2
- require 'rake'
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
@@ -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 = %q{i18n_generators}
8
- s.version = "1.0.2"
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.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
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
- if s.respond_to? :specification_version then
85
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
86
- s.specification_version = 3
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
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
89
- else
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
- uri = URI.parse "https://github.com/svenfuchs/rails-i18n/raw/master/rails/locale/#{locale_name}.yml"
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 = model_filenames.map do |model_name|
36
- model = begin
37
- m = model_name.camelize.constantize rescue LoadError
38
- next if m.nil? || !m.table_exists? || !m.respond_to?(:content_columns)
39
- m.class_eval %Q[def self._english_name; "#{model_name}"; end]
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._english_name}"}
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._english_name}.#{c.name}"}
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
- require File.join(File.dirname(__FILE__), 'yaml_waml')
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("--- \n", '').chomp.rstrip
51
+ @text = indent + @yaml.to_yaml.sub(/--- ?\n/, '').chomp.rstrip
48
52
  end
49
53
  end
50
54
 
@@ -0,0 +1,3 @@
1
+ module I18nGenerators
2
+ VERSION = '1.0.3'
3
+ end
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: 19
5
- prerelease: false
4
+ hash: 17
5
+ prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 2
10
- version: 1.0.2
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: 2010-11-29 00:00:00 +09:00
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: ronnie@dio.jp
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
- has_rdoc: true
83
- homepage: http://github.com/amatsuda/i18n_generators/
84
- licenses: []
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.3.7
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