i18n-tasks 0.2.4 → 0.2.5
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 +4 -4
- data/README.md +39 -2
- data/i18n-tasks.gemspec +24 -23
- data/lib/i18n/tasks.rb +1 -1
- data/lib/i18n/tasks/configuration.rb +1 -1
- data/lib/i18n/tasks/data/yaml.rb +3 -2
- data/lib/i18n/tasks/railtie.rb +5 -3
- data/lib/i18n/tasks/version.rb +1 -1
- data/lib/tasks/i18n-tasks.rake +4 -7
- data/spec/support/test_codebase_env.rake +4 -0
- metadata +6 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4b6ca864b87be5f8d5c8a1c6be42ebe3c4c4ec3c
|
|
4
|
+
data.tar.gz: 41133bde7863a0b57c9d14889ea4d56846c0c543
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 583ff94e1c15d0946de46f2dcf4a20ab9ea348a2f4ce9b60feabfbbd6e5123ae0e0fb9860c4fda7481ff5b60ab7011103cd67b646673395c16cf37dac8bf3827
|
|
7
|
+
data.tar.gz: 0d40adb4b4d03cd123aa9e099a65784fbf936da6eaaa780fa6dd1e936c769aeb5932cdc124b699f801200f11d283bba8d69b10814ffd8589cc39bc8372a8fef4
|
data/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# i18n-tasks [](https://travis-ci.org/glebm/i18n-tasks) [](https://coveralls.io/r/glebm/i18n-tasks?branch=master) [](https://codeclimate.com/github/glebm/i18n-tasks)
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
Tasks to manage translations in
|
|
4
|
+
Tasks to manage translations in ruby applications using I18n.
|
|
5
5
|
|
|
6
6
|

|
|
7
7
|
|
|
@@ -10,6 +10,7 @@ Tasks to manage translations in Rails.
|
|
|
10
10
|
Use `rake -T i18n` to get the list of tasks with descriptions. These are [the tasks](/lib/tasks/i18n-tasks.rake) available:
|
|
11
11
|
|
|
12
12
|
There are reports for missing and unused translations:
|
|
13
|
+
|
|
13
14
|
```bash
|
|
14
15
|
rake i18n:missing
|
|
15
16
|
rake i18n:unused
|
|
@@ -20,6 +21,7 @@ rake i18n:spreadsheet_report
|
|
|
20
21
|
i18n-tasks can add missing keys to the locale data, and it can also fill untranslated values.
|
|
21
22
|
|
|
22
23
|
To add the keys that are not in the base locale but detected in the source do:
|
|
24
|
+
|
|
23
25
|
```bash
|
|
24
26
|
# add missing keys to the base locale data (I18n.default_locale)
|
|
25
27
|
# values set to key.humanize
|
|
@@ -29,11 +31,13 @@ rake i18n:add_missing[OhNoesMissing]
|
|
|
29
31
|
```
|
|
30
32
|
|
|
31
33
|
Add blank yaml keys - `key: ''` for all missing and untranslated keys:
|
|
34
|
+
|
|
32
35
|
```bash
|
|
33
36
|
rake i18n:fill:blanks
|
|
34
37
|
```
|
|
35
38
|
|
|
36
39
|
Prefill empty translations using Google Translate:
|
|
40
|
+
|
|
37
41
|
```bash
|
|
38
42
|
rake i18n:fill:google_translate
|
|
39
43
|
# this task and the ones below can also accept specific locales:
|
|
@@ -45,6 +49,7 @@ rake i18n:fill:base_value
|
|
|
45
49
|
```
|
|
46
50
|
|
|
47
51
|
i18n-tasks sorts the keys and writes them to their respective files:
|
|
52
|
+
|
|
48
53
|
```bash
|
|
49
54
|
# this happens automatically on any i18n:fill:* task
|
|
50
55
|
rake i18n:normalize
|
|
@@ -68,7 +73,14 @@ For more examples see [the tests](/spec/i18n_tasks_spec.rb).
|
|
|
68
73
|
Simply add to Gemfile:
|
|
69
74
|
|
|
70
75
|
```ruby
|
|
71
|
-
gem 'i18n-tasks', '~> 0.2.
|
|
76
|
+
gem 'i18n-tasks', '~> 0.2.5'
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
If you do not use Rails, you will also need to require the tasks in your Rakefile:
|
|
80
|
+
|
|
81
|
+
```ruby
|
|
82
|
+
# Rakefile
|
|
83
|
+
load 'tasks/i18n-tasks.rake'
|
|
72
84
|
```
|
|
73
85
|
|
|
74
86
|
## Configuration
|
|
@@ -172,6 +184,31 @@ ignore:
|
|
|
172
184
|
- kaminari.*
|
|
173
185
|
```
|
|
174
186
|
|
|
187
|
+
## RSpec integration
|
|
188
|
+
|
|
189
|
+
You might want to test for missing and unused translations as part of your test suite.
|
|
190
|
+
This is how you can do it with rspec:
|
|
191
|
+
|
|
192
|
+
```ruby
|
|
193
|
+
# spec_helper.rb
|
|
194
|
+
require 'i18n/tasks'
|
|
195
|
+
require 'i18n/tasks/base_task'
|
|
196
|
+
|
|
197
|
+
# spec/locales_spec.rb
|
|
198
|
+
require 'spec_helper'
|
|
199
|
+
describe 'translations' do
|
|
200
|
+
let(:i18n) { I18n::Tasks::BaseTask.new }
|
|
201
|
+
|
|
202
|
+
it 'are all used' do
|
|
203
|
+
i18n.unused_keys.should have(0).keys
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
it 'are all present' do
|
|
207
|
+
i18n.untranslated_keys.should have(0).keys
|
|
208
|
+
end
|
|
209
|
+
end
|
|
210
|
+
```
|
|
211
|
+
|
|
175
212
|
## HTML report
|
|
176
213
|
|
|
177
214
|
While i18n-tasks does not provide an HTML version of the report, it's easy to roll your own, see [the example](https://gist.github.com/glebm/6887030).
|
data/i18n-tasks.gemspec
CHANGED
|
@@ -3,32 +3,33 @@ lib = File.expand_path('../lib', __FILE__)
|
|
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'i18n/tasks/version'
|
|
5
5
|
|
|
6
|
-
Gem::Specification.new do |
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
Gem::Specification.new do |s|
|
|
7
|
+
s.name = 'i18n-tasks'
|
|
8
|
+
s.version = I18n::Tasks::VERSION
|
|
9
|
+
s.authors = ['glebm']
|
|
10
|
+
s.email = ['glex.spb@gmail.com']
|
|
11
|
+
s.summary = %q{Tasks to manage missing and unused translations in ruby applications using I18n.}
|
|
12
|
+
s.description = %q{
|
|
13
13
|
rake tasks to find unused and missing translations, normalize locale files,
|
|
14
14
|
and prefill missing keys. Supports relative and plural keys and Google Translate.
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
s.homepage = 'https://github.com/glebm/i18n-tasks'
|
|
17
|
+
s.metadata = { 'issue_tracker' => 'https://github.com/glebm/i18n-tasks' }
|
|
18
|
+
s.license = 'MIT'
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
s.files = `git ls-files`.split($/) - %w(doc/img/i18n-tasks.gif)
|
|
21
|
+
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
22
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
|
23
|
+
s.require_paths = ['lib']
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
s.add_dependency 'rake'
|
|
26
|
+
s.add_dependency 'activesupport'
|
|
27
|
+
s.add_dependency 'easy_translate'
|
|
28
|
+
s.add_dependency 'term-ansicolor'
|
|
29
|
+
s.add_dependency 'terminal-table'
|
|
30
|
+
s.add_development_dependency 'axlsx', '~> 2.0'
|
|
31
|
+
s.add_development_dependency 'bundler', '~> 1.3'
|
|
32
|
+
s.add_development_dependency 'rake'
|
|
33
|
+
s.add_development_dependency 'rspec-rails'
|
|
34
|
+
s.add_development_dependency 'yard'
|
|
34
35
|
end
|
data/lib/i18n/tasks.rb
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
require 'i18n/tasks/version'
|
|
2
|
-
require 'i18n/tasks/railtie'
|
|
3
2
|
require 'active_support/core_ext/hash'
|
|
4
3
|
require 'active_support/core_ext/string'
|
|
5
4
|
require 'active_support/core_ext/module/delegation'
|
|
6
5
|
require 'active_support/core_ext/object/try'
|
|
7
6
|
require 'term/ansicolor'
|
|
7
|
+
require 'i18n/tasks/railtie' if defined?(Rails)
|
|
8
8
|
|
|
9
9
|
module I18n
|
|
10
10
|
module Tasks
|
data/lib/i18n/tasks/data/yaml.rb
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
require 'i18n/tasks/data_traversal'
|
|
2
2
|
require 'i18n/tasks/key_pattern_matching'
|
|
3
|
+
require 'yaml'
|
|
4
|
+
|
|
3
5
|
module I18n::Tasks
|
|
4
6
|
module Data
|
|
5
7
|
class Yaml
|
|
@@ -29,7 +31,6 @@ module I18n::Tasks
|
|
|
29
31
|
}
|
|
30
32
|
@locale_data = {}
|
|
31
33
|
end
|
|
32
|
-
attr_reader :config
|
|
33
34
|
|
|
34
35
|
# get locale tree
|
|
35
36
|
def get(locale)
|
|
@@ -68,4 +69,4 @@ module I18n::Tasks
|
|
|
68
69
|
alias []= set
|
|
69
70
|
end
|
|
70
71
|
end
|
|
71
|
-
end
|
|
72
|
+
end
|
data/lib/i18n/tasks/railtie.rb
CHANGED
data/lib/i18n/tasks/version.rb
CHANGED
data/lib/tasks/i18n-tasks.rake
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
require 'set'
|
|
2
|
+
require 'i18n/tasks'
|
|
2
3
|
require 'i18n/tasks/base_task'
|
|
3
4
|
require 'i18n/tasks/reports/terminal'
|
|
4
5
|
require 'active_support/core_ext/module/delegation'
|
|
5
6
|
require 'i18n/tasks/reports/spreadsheet'
|
|
6
7
|
|
|
7
8
|
namespace :i18n do
|
|
9
|
+
task :setup do
|
|
10
|
+
end
|
|
11
|
+
|
|
8
12
|
desc 'show missing translations'
|
|
9
13
|
task :missing => 'i18n:setup' do
|
|
10
14
|
i18n_report.missing_translations
|
|
@@ -57,13 +61,6 @@ namespace :i18n do
|
|
|
57
61
|
end
|
|
58
62
|
end
|
|
59
63
|
|
|
60
|
-
task 'i18n:setup' => :environment do
|
|
61
|
-
if File.exists?('.i18nignore')
|
|
62
|
-
I18n::Tasks.warn_deprecated "Looks like you are using .i18ignore. It is no longer used in favour of config/i18n-tasks.yml.\n
|
|
63
|
-
See README.md https://github.com/glebm/i18n-tasks"
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
|
|
67
64
|
module ::I18n::Tasks::RakeHelpers
|
|
68
65
|
include Term::ANSIColor
|
|
69
66
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: i18n-tasks
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- glebm
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2013-11-
|
|
11
|
+
date: 2013-11-29 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rake
|
|
@@ -210,7 +210,8 @@ files:
|
|
|
210
210
|
homepage: https://github.com/glebm/i18n-tasks
|
|
211
211
|
licenses:
|
|
212
212
|
- MIT
|
|
213
|
-
metadata:
|
|
213
|
+
metadata:
|
|
214
|
+
issue_tracker: https://github.com/glebm/i18n-tasks
|
|
214
215
|
post_install_message:
|
|
215
216
|
rdoc_options: []
|
|
216
217
|
require_paths:
|
|
@@ -230,7 +231,8 @@ rubyforge_project:
|
|
|
230
231
|
rubygems_version: 2.1.11
|
|
231
232
|
signing_key:
|
|
232
233
|
specification_version: 4
|
|
233
|
-
summary: Tasks to manage missing and unused translations in
|
|
234
|
+
summary: Tasks to manage missing and unused translations in ruby applications using
|
|
235
|
+
I18n.
|
|
234
236
|
test_files:
|
|
235
237
|
- spec/fixtures/app/assets/javascripts/application.js
|
|
236
238
|
- spec/fixtures/app/controllers/events_controller.rb
|