README.md in i18n-tasks-0.3.11 vs README.md in i18n-tasks-0.4.0.beta1
- old
+ new
@@ -16,11 +16,11 @@
## Installation
Add to Gemfile:
```ruby
-gem 'i18n-tasks', '~> 0.3.10'
+gem 'i18n-tasks', '~> 0.3.11'
```
i18n-tasks does not load or execute any of the application's code but performs static-only analysic.
This means you can install the gem and run it on a project without adding it to Gemfile.
@@ -43,10 +43,11 @@
find show where the keys are used in the code
normalize normalize translation data: sort and move to the right files
remove-unused remove unused keys
config display i18n-tasks configuration
xlsx-report save missing and unused translations to an Excel file
+ irb irb session within i18n-tasks context
See `<command> --help` for more information on a specific command.
```
#### Add missing keys
@@ -88,10 +89,17 @@
i18n-tasks find '{number,currency}.format.*'
```
![i18n-screenshot][screenshot-find]
+### Find / remove unused keys
+
+```bash
+i18n-tasks unused
+i18n-tasks remove-unused
+```
+
#### Features
Relative keys (`t '.title'`) and plural keys (`key.{one,many,other,...}`) are fully supported.
Scope argument is supported, but only when it is the first keyword argument ([improvements welcome](/lib/i18n/tasks/scanners/pattern_with_scope_scanner.rb)):
@@ -142,29 +150,54 @@
line_width: -1
```
#### Multiple locale files
-Use `data.read` and `data.write` options to work with locale data spread over multiple files.
+Use `data` options to work with locale data spread over multiple files.
+`data.read` accepts a list of file globs to read from per-locale:
+
```
# config/i18n-tasks.yml
data:
- # a list of file globs to read from per-locale
read:
# read from namespaced files, e.g. simple_form.en.yml
- 'config/locales/*.%{locale}.yml'
# read from a gem (config is parsed with ERB first, then YAML)
- "<%= %x[bundle show vagrant].chomp %>/templates/locales/%{locale}.yml"
# default
- 'config/locales/%{locale}.yml'
+```
+
+For writing to locale files i18n-tasks provides 2 options.
+
+##### Pattern router
+
+Pattern router organizes keys based on a list of key patterns, as in the example below:
+
+```
+data:
+ # pattern_router is default
+ router: pattern_router
# a list of {key pattern => file} routes, matched top to bottom
write:
# write models.* and views.* keys to the respective files
- ['{models,views}.*', 'config/locales/\1.%{locale}.yml']
# or, write every top-level key namespace to its own file
- ['{:}.*', 'config/locales/\1.%{locale}.yml']
# default, sugar for ['*', path]
+ - 'config/locales/%{locale}.yml'
+```
+
+##### Conservative router (v0.4.0+)
+
+Conservative router keeps the keys where they are found, or infers the path from base locale.
+If the key is completely new, conservative router will fall back to the pattern router behaviour.
+
+```
+data:
+ router: conservative_router
+ write:
- 'config/locales/%{locale}.yml'
```
#### Key pattern syntax