i18n-tasks 0.7.3 → 0.7.4

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: ace77283059f5ec38fb4cf6eb85d51fa72ee175f
4
- data.tar.gz: 2a9dc502ce2169a6c0e31a100346ff8ce8602c95
3
+ metadata.gz: a0d5a6d44abbe13489dbf413f1fe2934f96ac3ec
4
+ data.tar.gz: b73c633dbb50493e77f248a4d019473d38920c6e
5
5
  SHA512:
6
- metadata.gz: fbb5e12fdd92b788e8f88fd755195bc7d6040e22221b7d7087d16e5d011bfae89109a6fe425fbcdab4d264955ddcd5c2877f17e66ebd663396f48aa3faeabead
7
- data.tar.gz: bcf27a97b3fee099d9c1826f69e892060518e0fcc4d84ae89f64a4f638300e9faa4b6504396ddfe558153a1f689ecb21f6b683c581789354772dc38da275c662
6
+ metadata.gz: 33f1b9a719ad5a1127be44b0513aa9e0f2cd46598c2d855c46be9fbb9e488164c4eacddbd0d7ef0da28e4db7ffd922162770d8dbe883acdb45cf5d8d44dfb28b
7
+ data.tar.gz: 625b026add3aa686380a485df1f1db04ab450092eac690d793eb0293f237752c823702164ec13e662a3d7e4d5717a0dd840bfebe41d65f796f97abacd58bef12
data/CHANGES.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 0.7.4
2
+
3
+ * Fix `add-missing --help`
4
+ * Fix a minor issue with `health` #88(https://github.com/glebm/i18n-tasks/issues/88)
5
+
1
6
  ## 0.7.3
2
7
 
3
8
  * New task `translate-tree`
data/README.md CHANGED
@@ -25,7 +25,7 @@ i18n-tasks can be used with any project using [i18n][i18n-gem] (default in Rails
25
25
  Add to Gemfile:
26
26
 
27
27
  ```ruby
28
- gem 'i18n-tasks', '~> 0.7.3'
28
+ gem 'i18n-tasks', '~> 0.7.4'
29
29
  ```
30
30
 
31
31
  Copy default [configuration file](#configuration) (optional):
@@ -46,7 +46,7 @@ Run `i18n-tasks` to get the list of all the tasks with short descriptions.
46
46
 
47
47
  ### Check health
48
48
 
49
- `i18n-tasks health` will tell you any keys are missing or not used:
49
+ `i18n-tasks health` checks if any keys are missing or not used:
50
50
 
51
51
  ```console
52
52
  $ i18n-tasks health
@@ -60,26 +60,23 @@ Add missing keys with placeholders (base value or humanized key):
60
60
  $ i18n-tasks add-missing
61
61
  ```
62
62
 
63
- Most tasks also accept arguments:
63
+ This and other tasks accept arguments:
64
64
 
65
65
  ```console
66
66
  $ i18n-tasks add-missing -v 'TRME %{value}' fr
67
- $ i18n-tasks add-missing --help
68
- Usage: i18n-tasks add_missing [options] [locale ...]
69
- -l, --locales Comma-separated list of locale(s) to process. Default: all. Special: base.
70
- -f, --format Output format: terminal-table, yaml, json, keys, inspect. Default: terminal-table.
71
- -v, --value Value. Interpolates: %{value}, %{human_key}, %{value_or_human_key}. Default: %{value_or_human_key}
72
- -h, --help Display this help message.
73
67
  ```
74
68
 
75
- `i18n-tasks` also provides low-level composable tasks for fine-grained locale data manipulation. The above is equivalent to:
69
+ Pass `--help` for more information:
76
70
 
77
71
  ```console
78
- $ i18n-tasks missing -fyaml fr | i18n-tasks tree-set-value 'TRME %{value}' | i18n-tasks data-merge
72
+ $ i18n-tasks add-missing --help
73
+ Usage: i18n-tasks add-missing [options] [locale ...]
74
+ -l, --locales Comma-separated list of locale(s) to process. Default: all. Special: base.
75
+ -f, --format Output format: terminal-table, yaml, json, keys, inspect. Default: terminal-table.
76
+ -v, --value Value. Interpolates: %{value}, %{human_key}, %{value_or_human_key}. Default: %{value_or_human_key}.
77
+ -h, --help Display this help message.
79
78
  ```
80
79
 
81
- See command help for more information.
82
-
83
80
  ### Google Translate missing keys
84
81
 
85
82
  Translate missing values with Google Translate ([more below on the API key](#translation-config)).
@@ -109,15 +106,9 @@ $ i18n-tasks unused
109
106
  $ i18n-tasks remove-unused
110
107
  ```
111
108
 
112
- These tasks will infer dynamic key usage such as `t("category.\#{category.name}")` by default.
109
+ These tasks will infer [dynamic keys](#dynamic-keys) such as `t("category.\#{category.name}")` by default.
113
110
  Pass `-s` or `--strict` to disable this feature.
114
111
 
115
- `i18n-tasks remove-unused` is roughly equivalent to:
116
-
117
- ```bash
118
- $ i18n-tasks unused -fyaml | i18n-tasks data-remove
119
- ```
120
-
121
112
  ### Normalize data
122
113
 
123
114
  Sort the keys:
@@ -132,26 +123,57 @@ Sort the keys, and move them to the respective files as defined by (`config.writ
132
123
  $ i18n-tasks normalize -p
133
124
  ```
134
125
 
135
- ### Features
126
+ ### Compose tasks
136
127
 
137
- Relative keys (`t '.title'`) and plural keys (`key.{one,many,other,...}`) are fully supported.
138
- Scope argument is supported, but only when it is the first keyword argument ([improvements welcome](/lib/i18n/tasks/scanners/pattern_with_scope_scanner.rb)):
128
+ `i18n-tasks` also provides composable tasks for reading, writing and manipulating locale data.
139
129
 
140
- ```ruby
141
- # this is supported
142
- t :invalid, scope: [:auth, :password], attempts: 5
143
- # but not this
144
- t :invalid, attempts: 5, scope: [:auth, :password]
130
+ For example, `add-missing` implemented with `missing`, `tree-set-value` and `data-merge`:
131
+
132
+ ```console
133
+ $ i18n-tasks missing -fyaml fr | i18n-tasks tree-set-value 'TRME %{value}' | i18n-tasks data-merge
134
+ ```
135
+
136
+ Another example, `remove-unused` implemented with `unused` and `data-remove`:
137
+
138
+ ```bash
139
+ $ i18n-tasks unused -fyaml | i18n-tasks data-remove
145
140
  ```
146
141
 
147
- Unused report will detect certain dynamic key forms and not report them, e.g.:
142
+ See the full list of tasks with `i18n-tasks --help`.
143
+
144
+ ### Features and limitations
145
+
146
+ #### Relative keys
147
+
148
+ `i18n-tasks` offers partial support for relative keys, such as `t '.title'`.
149
+
150
+ ✔ Keys relative to the file path they are used in (see [relative roots configuration](#usage-search)) are supported.
151
+
152
+ ✘ Keys relative to `controller.action_name` in Rails controllers are not supported.
153
+
154
+ #### Plural keys
155
+
156
+ ✔ Plural keys, such as `key.{one,many,other,...}` are fully supported.
157
+
158
+ #### `t()` keyword arguments
159
+
160
+ ✔ `scope` keyword argument is supported, but only when it is the first argument.
161
+
162
+ ✘ `default` and other arguments are not supported.
163
+
164
+ Parsing keyword arguments correctly with Regexp is difficult. This can be improved with an s-expression parser.
165
+
166
+ #### Dynamic keys
167
+
168
+ By default, unused report will detect some dynamic keys and not report them, e.g.:
148
169
 
149
170
  ```ruby
150
- t 'category.' + category.key # all 'category.*' keys are considered used
151
- t "category.#{category.key}.name" # all 'category.*.name' keys are considered used
171
+ t 'category.' + category.key # all 'category.:' keys considered used (: denotes one key segment)
172
+ t "category.#{category.key}.name" # all 'category.:.name' keys considered used
152
173
  ```
153
174
 
154
- Translation data storage, key usage search, and other [settings](#configuration) are compatible with Rails by default.
175
+ This will not be on by default in future versions, in favour of encouraging explicit [i18n-tasks-use hints](#fine-tuning).
176
+ For now, you can disable dynamic key inference by passing `-s` or `--strict` to `unused` tasks.
155
177
 
156
178
  ## Configuration
157
179
 
@@ -164,6 +186,8 @@ Install the default config file with:
164
186
  $ cp $(i18n-tasks gem-path)/templates/config/i18n-tasks.yml config/
165
187
  ```
166
188
 
189
+ Settings are compatible with Rails by default.
190
+
167
191
  ### Locales
168
192
 
169
193
  By default, `base_locale` is set to `en` and `locales` are inferred from the paths to data files.
@@ -389,8 +413,8 @@ Add a custom task like the ones defined by the gem:
389
413
  # my_commands.rb
390
414
  class MyCommands
391
415
  include ::I18n::Tasks::Command::Collection
392
- cmd :my_command, desc: 'my custom command'
393
- def my_command(opts = {})
416
+ cmd :my_task, desc: 'my custom task'
417
+ def my_task(opts = {})
394
418
  end
395
419
  end
396
420
  ```
@@ -38,7 +38,7 @@ module I18n::Tasks
38
38
  args: '[locale ...]',
39
39
  desc: proc { I18n.t('i18n_tasks.cmd.desc.add_missing') },
40
40
  opt: cmd_opts(:locales, :out_format) <<
41
- cmd_opt(:value).merge(desc: "#{cmd_opt(:value)[:desc]}. #{I18n.t('i18n_tasks.cmd.args.default_text', value: DEFAULT_ADD_MISSING_VALUE)}")
41
+ cmd_opt(:value).merge(desc: proc { "#{cmd_opt(:value)[:desc].call}. #{I18n.t('i18n_tasks.cmd.args.default_text', value: DEFAULT_ADD_MISSING_VALUE)}" })
42
42
 
43
43
  def add_missing(opt = {})
44
44
  forest = i18n.missing_keys(opt).set_each_value!(opt[:value] || DEFAULT_ADD_MISSING_VALUE)
@@ -3,9 +3,10 @@ module I18n::Tasks::SlopCommand
3
3
 
4
4
  def slop_command(name, attr, &block)
5
5
  proc {
6
- command name.tr('_', '-') do
6
+ cmd_name = name.tr('_', '-')
7
+ command cmd_name do
7
8
  args = attr[:args]
8
- banner "Usage: i18n-tasks #{name} [options] #{args}" if args.present?
9
+ banner "Usage: i18n-tasks #{cmd_name} [options] #{args}" if args.present?
9
10
  desc = attr[:desc]
10
11
  desc = desc.call if desc.respond_to?(:call)
11
12
  description desc if desc
@@ -12,7 +12,7 @@ module I18n::Tasks
12
12
  locale_count: locale_count,
13
13
  per_locale_avg: forest.inject(0) { |sum, f| sum + f.leaves.count } / locale_count,
14
14
  key_segments_avg: '%.1f' % (forest.leaves.inject(0) { |sum, node| sum + node.walk_to_root.count - 1 } / key_count.to_f),
15
- value_chars_avg: forest.leaves.inject(0) { |sum, node| sum + node.value.length } / key_count
15
+ value_chars_avg: forest.leaves.inject(0) { |sum, node| sum + node.value.to_s.length } / key_count
16
16
  }
17
17
  end
18
18
  end
@@ -1,6 +1,6 @@
1
1
  # coding: utf-8
2
2
  module I18n
3
3
  module Tasks
4
- VERSION = '0.7.3'
4
+ VERSION = '0.7.4'
5
5
  end
6
6
  end
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.7.3
4
+ version: 0.7.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - glebm
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-07 00:00:00.000000000 Z
11
+ date: 2014-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: erubis