rails-i18n-updater 1.0.0

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
+ /rails-i18n-updater.gemspec
2
+ /pkg
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Andreas Neuhaus
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,51 @@
1
+ Rails plugin to fetch and update core translations
2
+ ==================================================
3
+
4
+ This Rails plugin adds Rails core translations to your application.
5
+
6
+ Rails core translations are downloaded from <http://github.com/svenfuchs/rails-i18n> by default.
7
+
8
+ Install
9
+ -------
10
+
11
+ Add the rails-i18n-updater gem to your Rails application. With Rails 3.x, add the
12
+ following to you `Gemfile`:
13
+
14
+ gem 'rails-i18n-updater'
15
+
16
+ Use the i18n:update task to initially download core translations:
17
+
18
+ $ rake i18n:update
19
+
20
+ If you're using Rails 2.x without Bundler, you need to add `config.gem 'rails-i18n-updater'`
21
+ to `config/environments.rb`. Also, you need to manually include the i18n:update task by
22
+ adding `require 'rails_i18n_updater/tasks'` to your application's `Rakefile`.
23
+
24
+ If you previously used the rails-i18n-updater plugin, you should remove it after
25
+ switching to the gem by simply deleting the directory `vendor/plugins/rails-i18n-updater`
26
+ in your application.
27
+
28
+ Update
29
+ ------
30
+
31
+ To update to the latest core translations, use:
32
+
33
+ $ rake i18n:update
34
+
35
+ How it works
36
+ ------------
37
+
38
+ The plugin provides the rake task `i18n:update` which uses `git` to download the latest core translations to `vendor/rails-locales`. This rake task can be started manually whenever you want to update to the latest core translations.
39
+
40
+ On application start, the plugin automatically adds downloaded core translations to `I18n.load_path`. Only locales you used in your applications are added and they're prepended to the load path so you can override the defaults in your own locale files.
41
+
42
+ Limitations
43
+ -----------
44
+
45
+ - You need `git` in your PATH for `rake i18n:update` to work correctly.
46
+ - Your application must use the simple I18n backend (using .yml or .rb files for locales).
47
+
48
+ Author
49
+ ------
50
+
51
+ Andreas Neuhaus :: <http://zargony.com/>
data/Rakefile ADDED
@@ -0,0 +1,39 @@
1
+ require 'rake'
2
+
3
+ desc 'Default: run unit tests.'
4
+ task :default => :test
5
+
6
+ require 'jeweler'
7
+ Jeweler::Tasks.new do |gem|
8
+ gem.name = 'rails-i18n-updater'
9
+ gem.summary = 'Rails plugin to automatically fetch and update Rails core translations in a Rails application'
10
+ gem.description = 'This Rails plugin provides the rake task i18n:update to download the latest core translations to vendor/rails-locales. On application start, the plugin automatically prepends downloaded core translations to the I18n load_path. So the downloaded core translations are automatically used in your application, but you can still override the defaults in your own locale files.'
11
+ gem.homepage = 'http://github.com/zargony/rails-i18n-updater'
12
+ gem.authors = ['Andreas Neuhaus']
13
+ gem.add_dependency 'activesupport'
14
+ gem.add_dependency 'actionpack'
15
+ gem.add_dependency 'rails'
16
+ gem.has_rdoc = false
17
+ gem.add_development_dependency 'mocha'
18
+ end
19
+ Jeweler::GemcutterTasks.new
20
+
21
+ require 'rake/testtask'
22
+ task :test => :check_dependencies
23
+ desc 'Test the rails-i18n-updater plugin.'
24
+ Rake::TestTask.new(:test) do |test|
25
+ test.libs << 'lib' << 'test'
26
+ test.pattern = 'test/**/test_*.rb'
27
+ test.verbose = true
28
+ end
29
+
30
+ require 'rake/rdoctask'
31
+ desc 'Generate documentation for the rails-i18n-updater plugin.'
32
+ Rake::RDocTask.new(:rdoc) do |rdoc|
33
+ version = File.exist?('VERSION') ? File.read('VERSION') : ''
34
+ rdoc.rdoc_dir = 'rdoc'
35
+ rdoc.title = "Rails I18N Updater #{version}"
36
+ rdoc.options << '--line-numbers' << '--inline-source'
37
+ rdoc.rdoc_files.include('README')
38
+ rdoc.rdoc_files.include('lib/**/*.rb')
39
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.0
@@ -0,0 +1 @@
1
+ require 'rails_i18n_updater'
@@ -0,0 +1,27 @@
1
+ require 'rails/version'
2
+ require 'rails_i18n_updater/config'
3
+
4
+ module RailsI18nUpdater
5
+
6
+ # Prepare load path: add Rails core locales to I18n.load_path
7
+ # - only add locales that are actually used in the application
8
+ # - prepend locales so that they can be overwritten by the application
9
+ def self.prepare_i18n_load_path
10
+ used_locales = I18n.load_path.map { |f| File.basename(f).gsub(/\.(rb|yml)$/, '') }.uniq
11
+ files_to_add = Dir[File.join(RailsI18nUpdater::Config.local_path, '**', "{#{used_locales.join(',')}}.{rb,yml}")]
12
+ I18n.load_path.unshift(*files_to_add)
13
+ end
14
+ end
15
+
16
+ # Prepare new load path in after_initialize as the I18n.load_path might
17
+ # be modified in Rails initializers.
18
+ case Rails::VERSION::MAJOR
19
+ when 3
20
+ require 'rails_i18n_updater/railtie'
21
+ when 2
22
+ Rails.configuration.after_initialize do
23
+ RailsI18nUpdater.prepare_i18n_load_path
24
+ end
25
+ else
26
+ STDERR.puts "WARNING: Rails I18n Updater not loading. Unsupported Rails version #{Rails::VERSION::STRING}"
27
+ end
@@ -0,0 +1,25 @@
1
+ module RailsI18nUpdater
2
+ class Config
3
+ class << self
4
+ # Repository URL to fetch locales from
5
+ def repository_url
6
+ 'git://github.com/svenfuchs/rails-i18n.git'
7
+ end
8
+
9
+ # Repository branch to use
10
+ def repository_branch
11
+ 'master'
12
+ end
13
+
14
+ # Path within repository to fetch
15
+ def repository_path
16
+ 'rails/locale'
17
+ end
18
+
19
+ # Local path where to store fetched locales
20
+ def local_path
21
+ File.join(Rails.root, 'vendor', 'rails-locales')
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,14 @@
1
+ require 'rails'
2
+
3
+ module RailsI18nUpdater
4
+ class Railtie < Rails::Railtie
5
+ initializer 'rails_i18n_updater.initialize' do
6
+ config.after_initialize do
7
+ RailsI18nUpdater.prepare_i18n_load_path
8
+ end
9
+ end
10
+ rake_tasks do
11
+ load File.join(File.dirname(__FILE__), 'tasks.rb')
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,16 @@
1
+ namespace :i18n do
2
+ desc 'Update (download) Rails core translations'
3
+ task :update do
4
+ require 'rails_i18n_updater/config'
5
+ temp_path = "#{RailsI18nUpdater::Config.local_path}.tmp"
6
+ sh <<-EOC
7
+ rm -rf #{temp_path} && \
8
+ git clone -q --depth 1 #{RailsI18nUpdater::Config.repository_url} #{temp_path} && \
9
+ cd #{temp_path} && \
10
+ git checkout -q #{RailsI18nUpdater::Config.repository_branch} && \
11
+ rm -rf #{RailsI18nUpdater::Config.local_path} && \
12
+ mv #{File.join(temp_path, RailsI18nUpdater::Config.repository_path)} #{RailsI18nUpdater::Config.local_path} && \
13
+ rm -rf #{temp_path}
14
+ EOC
15
+ end
16
+ end
data/rails/init.rb ADDED
@@ -0,0 +1 @@
1
+ require 'rails_i18n_updater'
metadata ADDED
@@ -0,0 +1,126 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails-i18n-updater
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 1
7
+ - 0
8
+ - 0
9
+ version: 1.0.0
10
+ platform: ruby
11
+ authors:
12
+ - Andreas Neuhaus
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-08-12 00:00:00 +02:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: activesupport
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
30
+ version: "0"
31
+ type: :runtime
32
+ version_requirements: *id001
33
+ - !ruby/object:Gem::Dependency
34
+ name: actionpack
35
+ prerelease: false
36
+ requirement: &id002 !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ segments:
42
+ - 0
43
+ version: "0"
44
+ type: :runtime
45
+ version_requirements: *id002
46
+ - !ruby/object:Gem::Dependency
47
+ name: rails
48
+ prerelease: false
49
+ requirement: &id003 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ segments:
55
+ - 0
56
+ version: "0"
57
+ type: :runtime
58
+ version_requirements: *id003
59
+ - !ruby/object:Gem::Dependency
60
+ name: mocha
61
+ prerelease: false
62
+ requirement: &id004 !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ segments:
68
+ - 0
69
+ version: "0"
70
+ type: :development
71
+ version_requirements: *id004
72
+ description: This Rails plugin provides the rake task i18n:update to download the latest core translations to vendor/rails-locales. On application start, the plugin automatically prepends downloaded core translations to the I18n load_path. So the downloaded core translations are automatically used in your application, but you can still override the defaults in your own locale files.
73
+ email:
74
+ executables: []
75
+
76
+ extensions: []
77
+
78
+ extra_rdoc_files:
79
+ - LICENSE
80
+ - README.md
81
+ files:
82
+ - .gitignore
83
+ - LICENSE
84
+ - README.md
85
+ - Rakefile
86
+ - VERSION
87
+ - lib/rails-i18n-updater.rb
88
+ - lib/rails_i18n_updater.rb
89
+ - lib/rails_i18n_updater/config.rb
90
+ - lib/rails_i18n_updater/railtie.rb
91
+ - lib/rails_i18n_updater/tasks.rb
92
+ - rails/init.rb
93
+ has_rdoc: true
94
+ homepage: http://github.com/zargony/rails-i18n-updater
95
+ licenses: []
96
+
97
+ post_install_message:
98
+ rdoc_options:
99
+ - --charset=UTF-8
100
+ require_paths:
101
+ - lib
102
+ required_ruby_version: !ruby/object:Gem::Requirement
103
+ none: false
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ segments:
108
+ - 0
109
+ version: "0"
110
+ required_rubygems_version: !ruby/object:Gem::Requirement
111
+ none: false
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ segments:
116
+ - 0
117
+ version: "0"
118
+ requirements: []
119
+
120
+ rubyforge_project:
121
+ rubygems_version: 1.3.7
122
+ signing_key:
123
+ specification_version: 3
124
+ summary: Rails plugin to automatically fetch and update Rails core translations in a Rails application
125
+ test_files: []
126
+