README.md in i18n-js-3.0.0.rc9 vs README.md in i18n-js-3.0.0.rc10
- old
+ new
@@ -36,10 +36,12 @@
```javascript
//
// This is optional (in case you have `I18n is not defined` error)
// If you want to put this line, you must put it BEFORE `i18n/translations`
//= require i18n
+// Some people even need to add the extension to make it work, see https://github.com/fnando/i18n-js/issues/283
+//= require i18n.js
//
// This is a must
//= require i18n/translations
```
@@ -95,11 +97,11 @@
```yaml
translations:
- file: "public/javascripts/i18n/%{locale}.js"
only: '*'
- file: "public/javascripts/frontend/i18n/%{locale}.js"
- only: ['frontend', 'users']
+ only: ['*.frontend', '*.users.*']
```
You can also include ERB in your config file.
```yaml
translations:
@@ -114,11 +116,11 @@
JS translations file (exported or generated by the middleware) will omit any
keys listed in `except` configuration param:
```yaml
translations:
- - except: ['active_admin', 'ransack']
+ - except: ['*.active_admin', '*.ransack', '*.activerecord.errors']
```
#### Export Configuration (For other things)
@@ -132,20 +134,29 @@
Default: `public/javascripts`
Behaviour:
- Any `String`: considered as a relative path for a folder to `Rails.root` and export `i18n.js` to that folder for `rake i18n:js:export`
- Any non-`String` (`nil`, `false`, `:none`, etc): Disable `i18n.js` exporting
-- You may also set `export_i18n_js` in your config file, e.g.:
+- `I18n::JS.sort_translation_keys`
+ Expected Type: `Boolean`
+ Default: `true`
+ Behaviour:
+ - Sets whether or not to deep sort all translation keys in order to generate identical output for the same translations
+ - Set to true to ensure identical asset fingerprints for the asset pipeline
+- You may also set `export_i18n_js` and `sort_translation_keys` in your config file, e.g.:
+
```yaml
export_i18n_js_: false
# OR
export_i18n_js: "my/path"
+sort_translation_keys: false
+
translations:
- ...
-``
+```
To find more examples on how to use the configuration file please refer to the tests.
#### Fallbacks
@@ -356,17 +367,24 @@
becomes "what is your favorite Christmas present"
In order to still detect untranslated strings, you can
i18n.missingTranslationPrefix to something like:
+```javascript
+I18n.missingTranslationPrefix = 'EE: ';
+```
- I18n.missingTranslationPrefix = 'EE: '
-
And result will be:
+```javascript
+"EE: what is your favorite Christmas present"
+```
- "EE: what is your favorite Christmas present"
-
This will help you doing automated tests against your localisation assets.
+
+Some people prefer returning `null` for missing translation:
+```javascript
+I18n.missingTranslation = function () { return undefined; };
+```
Pluralization is possible as well and by default provides English rules:
I18n.t("inbox.counting", {count: 10}); // You have 10 messages