i18n-tasks 0.2.11 → 0.2.12
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/CHANGES.md +1 -1
- data/README.md +27 -21
- data/lib/i18n/tasks/data/yaml.rb +4 -0
- data/lib/i18n/tasks/reports/terminal.rb +1 -1
- data/lib/i18n/tasks/unused_keys.rb +0 -1
- data/lib/i18n/tasks/version.rb +1 -1
- data/lib/tasks/i18n-tasks.rake +3 -1
- data/spec/i18n_tasks_spec.rb +3 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c0656504d782b473cf5f6af625b9c9192ab1a3b
|
4
|
+
data.tar.gz: 96add6aaaf63bf5403d24aa1824e95bf9b42037d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ef87ed54318dc731fe2122a76cf7a5bd3b6c4fd17ccbaf2b74ee6cdc7b8eaea506f89d93ebbbcc14ede756c4e7040bc22ce98021f68584d451180f6829213ac
|
7
|
+
data.tar.gz: dfd8dc48f5684027dd474cd460dac25018697cd29c50d08511022f4ea430133ede4e5aaca577f0dc90cde6b3e3140c2fce56036a2d1c065be76211de23a3feb1
|
data/CHANGES.md
CHANGED
data/README.md
CHANGED
@@ -19,14 +19,13 @@ rake i18n:unused
|
|
19
19
|
You can also export missing and unused data to XLSX though there is no importer yet:
|
20
20
|
|
21
21
|
```bash
|
22
|
-
# or save both to an XLSX file:
|
23
22
|
rake i18n:spreadsheet_report
|
24
23
|
```
|
25
24
|
|
26
|
-
|
25
|
+
To remove unused translations run:
|
27
26
|
|
28
27
|
```bash
|
29
|
-
rake i18n:remove_unused
|
28
|
+
rake i18n:remove_unused # this will print the unused report and ask for confirmation before deleting keys
|
30
29
|
```
|
31
30
|
|
32
31
|
i18n-tasks can add missing keys to the locale data, and it can also fill untranslated values.
|
@@ -41,19 +40,14 @@ rake i18n:add_missing
|
|
41
40
|
rake i18n:add_missing[OhNoesMissing]
|
42
41
|
```
|
43
42
|
|
44
|
-
|
45
|
-
|
46
|
-
```bash
|
47
|
-
rake i18n:fill:blanks
|
48
|
-
```
|
49
|
-
|
50
|
-
Prefill empty translations using Google Translate:
|
43
|
+
Prefill empty translations using Google Translate ([more below on the API key](#translation-config)).
|
51
44
|
|
52
45
|
```bash
|
53
46
|
rake i18n:fill:google_translate
|
54
47
|
# this task and the ones below can also accept specific locales:
|
55
48
|
rake i18n:fill:google_translate[es+de]
|
56
49
|
```
|
50
|
+
|
57
51
|
Prefill using values from the base locale - `I8n.default_locale`:
|
58
52
|
```bash
|
59
53
|
rake i18n:fill:base_value
|
@@ -92,11 +86,21 @@ If you do not use Rails, you will also need to require the tasks in your Rakefil
|
|
92
86
|
```ruby
|
93
87
|
# Rakefile
|
94
88
|
load 'tasks/i18n-tasks.rake'
|
89
|
+
|
90
|
+
# to prepare the environment add dependency to i18n:setup:
|
91
|
+
namespace :i18n do
|
92
|
+
task :setup => 'environment'
|
93
|
+
end
|
94
|
+
|
95
|
+
task :environment do
|
96
|
+
# set `I18n.avaliable_locales` and `I18.default_locale`, etc
|
97
|
+
# ...
|
98
|
+
end
|
95
99
|
```
|
96
100
|
|
97
101
|
## Configuration
|
98
102
|
|
99
|
-
Configuration is read from `config/i18n-tasks.yml`
|
103
|
+
Configuration is read from `config/i18n-tasks.yml` or `config/i18n-tasks.yml.erb`.
|
100
104
|
|
101
105
|
By default, `i18n-tasks` will work with `I18n.default_locale` and `I18n.available_locales`, but you can override this:
|
102
106
|
|
@@ -127,7 +131,7 @@ data:
|
|
127
131
|
- 'config/locales/%{locale}.yml' # path is short for ['*', path]
|
128
132
|
```
|
129
133
|
|
130
|
-
Key matching syntax
|
134
|
+
Key matching syntax:
|
131
135
|
|
132
136
|
| syntax | description |
|
133
137
|
|:------------:|:----------------------------------------------------------|
|
@@ -146,15 +150,6 @@ data:
|
|
146
150
|
- ['{:}.*', 'config/locales/\1.%{locale}.yml']
|
147
151
|
```
|
148
152
|
|
149
|
-
### Translation
|
150
|
-
|
151
|
-
Set `GOOGLE_TRANSLATE_API_KEY` environment variable, or specify the key in config/i18n-tasks.yml:
|
152
|
-
|
153
|
-
```yaml
|
154
|
-
translation:
|
155
|
-
api_key: THE_KEY
|
156
|
-
```
|
157
|
-
|
158
153
|
### Usage search
|
159
154
|
|
160
155
|
```yaml
|
@@ -206,6 +201,17 @@ ignore:
|
|
206
201
|
- kaminari.*
|
207
202
|
```
|
208
203
|
|
204
|
+
<a name="translation-config"></a>
|
205
|
+
### Google Translate
|
206
|
+
|
207
|
+
`rake i18n:fill:google_translate` requires a Google Translate API key, get it at [Google API Console](https://code.google.com/apis/console).
|
208
|
+
Put the key in `GOOGLE_TRANSLATE_API_KEY` environment variable or in the config file.
|
209
|
+
|
210
|
+
```yaml
|
211
|
+
translation:
|
212
|
+
api_key: <Google Translate API key>
|
213
|
+
```
|
214
|
+
|
209
215
|
## RSpec integration
|
210
216
|
|
211
217
|
You might want to test for missing and unused translations as part of your test suite.
|
data/lib/i18n/tasks/data/yaml.rb
CHANGED
@@ -22,7 +22,7 @@ module I18n
|
|
22
22
|
base_value = ''
|
23
23
|
else
|
24
24
|
locale = magenta rec[:locale]
|
25
|
-
base_value = cyan rec[:base_value].
|
25
|
+
base_value = cyan rec[:base_value].to_s.strip || ''
|
26
26
|
end
|
27
27
|
[{value: locale, alignment: :center},
|
28
28
|
{value: glyph, alignment: :center},
|
@@ -16,7 +16,6 @@ module I18n
|
|
16
16
|
def remove_unused!(locales = self.locales)
|
17
17
|
exclude = unused_keys.map(&:first).to_set
|
18
18
|
locales.each do |locale|
|
19
|
-
#require 'byebug'; byebug
|
20
19
|
data[locale] = list_to_tree traverse_map_if(data[locale]) { |key, value|
|
21
20
|
[key, value] unless exclude.include?(depluralize_key(locale, key))
|
22
21
|
}
|
data/lib/i18n/tasks/version.rb
CHANGED
data/lib/tasks/i18n-tasks.rake
CHANGED
@@ -49,7 +49,9 @@ namespace :i18n do
|
|
49
49
|
unused_keys = i18n_tasks.unused_keys
|
50
50
|
if unused_keys.present?
|
51
51
|
i18n_report.unused_translations(unused_keys)
|
52
|
-
|
52
|
+
unless ENV['CONFIRM']
|
53
|
+
exit 1 unless agree(red "All these translations will be removed in #{bold locales * ', '}#{red '.'} " + yellow('Continue? (yes/no)') + ' ')
|
54
|
+
end
|
53
55
|
i18n_tasks.remove_unused!(locales)
|
54
56
|
else
|
55
57
|
STDERR.puts bold green 'No unused keys to remove'
|
data/spec/i18n_tasks_spec.rb
CHANGED
@@ -33,8 +33,10 @@ describe 'rake i18n' do
|
|
33
33
|
t.t(t.data[:es], key).should be_present
|
34
34
|
end
|
35
35
|
|
36
|
-
|
36
|
+
ENV['CONFIRM'] = '1'
|
37
|
+
TestCodebase.capture_stderr { TestCodebase.rake_result('i18n:remove_unused') }
|
37
38
|
|
39
|
+
t.data.reload
|
38
40
|
# or save both to an xlsx file:
|
39
41
|
expected_unused_keys.each do |key|
|
40
42
|
t.t(t.data[:en], key).should be_nil
|
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.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- glebm
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|