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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e5f6e76606d7dd49f09c15b59a7cb0090cd7fde5
4
- data.tar.gz: 2a926a8c845b17edb62406c48bddc805ec1bcd37
3
+ metadata.gz: 2c0656504d782b473cf5f6af625b9c9192ab1a3b
4
+ data.tar.gz: 96add6aaaf63bf5403d24aa1824e95bf9b42037d
5
5
  SHA512:
6
- metadata.gz: 8ecf7561e9bbd78b4a0bc3ac08b25e9b0416129acb2dbc05ff465d0dd29f9925a5efb8396b217c87e3730db57b6f62a673c67272e0340f83fcf53aff946d41e0
7
- data.tar.gz: 3797630ebef48dd78885bce77e23a2ace0e9478dc2f2d54af9a1fd512896533a0d76ae6d98db23dfa064fdd03b19d745a2f13c0923b5b73df2fd0672b565b05d
6
+ metadata.gz: 7ef87ed54318dc731fe2122a76cf7a5bd3b6c4fd17ccbaf2b74ee6cdc7b8eaea506f89d93ebbbcc14ede756c4e7040bc22ce98021f68584d451180f6829213ac
7
+ data.tar.gz: dfd8dc48f5684027dd474cd460dac25018697cd29c50d08511022f4ea430133ede4e5aaca577f0dc90cde6b3e3140c2fce56036a2d1c065be76211de23a3feb1
data/CHANGES.md CHANGED
@@ -1,4 +1,4 @@
1
- ## v0.2.1
1
+ ## v0.2.11 .. v0.2.12
2
2
 
3
3
  * New task: `i18n:remove_unused`
4
4
 
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
- i18n-tasks can automatically remove all unused translations:
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
- Add blank yaml keys - `key: ''` for all missing and untranslated keys:
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` (processed with ERB then Yaml).
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 work this way:
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.
@@ -68,6 +68,10 @@ module I18n::Tasks
68
68
  end
69
69
 
70
70
  alias []= set
71
+
72
+ def reload
73
+ @locale_data = {}
74
+ end
71
75
  end
72
76
  end
73
77
  end
@@ -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].try(:strip) || ''
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
  }
@@ -1,5 +1,5 @@
1
1
  module I18n
2
2
  module Tasks
3
- VERSION = '0.2.11'
3
+ VERSION = '0.2.12'
4
4
  end
5
5
  end
@@ -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
- exit 1 unless agree(red "All these translations will be removed in #{bold locales * ', '}#{red '.'} " + yellow('Continue? (yes/no)') + ' ')
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'
@@ -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
- t.remove_unused!(t.locales)
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.11
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-06 00:00:00.000000000 Z
11
+ date: 2013-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake