README.md in i18n-js-3.7.1 vs README.md in i18n-js-3.8.0
- old
+ new
@@ -35,10 +35,22 @@
Add the gem to your Gemfile.
```ruby
gem "i18n-js"
```
+#### Rails with [webpacker](https://github.com/rails/webpacker)
+
+If you're using `webpacker`, you may need to add the dependencies to your client with:
+
+```
+yarn add i18n-js
+# or, if you're using npm,
+npm install i18n-js
+```
+
+For more details, see [this gist](https://gist.github.com/bazzel/ecdff4718962e57c2d5569cf01d332fe).
+
#### Rails app with [Asset Pipeline](http://guides.rubyonrails.org/asset_pipeline.html)
If you're using the [asset pipeline](http://guides.rubyonrails.org/asset_pipeline.html),
then you must add the following line to your `app/assets/javascripts/application.js`.
@@ -323,11 +335,11 @@
```
### Setting up
-You **don't** need to set up a thing. The default settings will work just okay. But if you want to split translations into several files or specify specific contexts, you can follow the rest of this setting up section.
+You **don't** need to set up a thing. The default settings will work just okay. But if you want to split translations into several files or specify contexts, you can follow the rest of this setting up section.
Set your locale is easy as
```javascript
I18n.defaultLocale = "pt-BR";
I18n.locale = "pt-BR";
@@ -391,11 +403,11 @@
// As a simple translation
I18n.t("some.missing.scope", {defaults: [{message: "Some message"}]});
```
-Default values must be provided as an array of hashs where the key is the
+Default values must be provided as an array of hashes where the key is the
type of translation desired, a `scope` or a `message`. The translation returned
will be either the first scope recognized, or the first message defined.
The translation will fallback to the `defaultValue` translation if no scope
in `defaults` matches and if no default of type `message` is found.
@@ -490,11 +502,11 @@
var key = count % 10 == 1 && count % 100 != 11 ? "one" : [2, 3, 4].indexOf(count % 10) >= 0 && [12, 13, 14].indexOf(count % 100) < 0 ? "few" : count % 10 == 0 || [5, 6, 7, 8, 9].indexOf(count % 10) >= 0 || [11, 12, 13, 14].indexOf(count % 100) >= 0 ? "many" : "other";
return [key];
};
```
-You can find all rules on <http://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html>.
+You can find all rules on <https://unicode-org.github.io/cldr-staging/charts/37/supplemental/language_plural_rules.html>.
If you're using the same scope over and over again, you may use the `scope` option.
```javascript
var options = {scope: "activerecord.attributes.user"};
@@ -572,10 +584,11 @@
- `precision`: defaults to `1`
- `separator`: defaults to `.`
- `delimiter`: defaults to `""`
- `strip_insignificant_zeros`: defaults to `false`
- `format`: defaults to `%n%u`
+- `scope`: defaults to `""`
<!---->
```javascript
I18n.toHumanSize(1234); // 1KB
@@ -726,11 +739,11 @@
### Using require.js / r.js
To use this with require.js we are only going to change a few things from above.
-1. In your `config/i18n-js.yml` we need to add a better location for the i18n to be exported. You want to use this location so that it can be properly precompiled by r.js.
+1. In your `config/i18n-js.yml` we need to add a better location for the i18n to be exported to. You want to use this location so that it can be properly precompiled by r.js.
```yaml
export_i18n_js: "app/assets/javascript/nls"
```
@@ -770,11 +783,11 @@
```javascript
define(['welcome/other_asset','nls/welcome'], function (otherAsset){
// ...
});
```
-4. (optional) As an additional configuration we can make a task to be run before the requirejs optimizer. This will allow any automated scripts that run the requirejs optimizer to export the strings before we run r.js
+4. (optional) As an additional configuration we can make a task to be run before the requirejs optimizer. This will allow any automated scripts that run the requirejs optimizer to export the strings before we run r.js.
```rake
# lib/tasks/i18n.rake
Rake::Task[:'i18n:js:export'].prerequisites.clear
task :'i18n:js:export' => :'i18n:js:before_export'
@@ -831,23 +844,23 @@
```bash
$ rake assets:precompile
```
-or similar commands. If you are precompiling assets on the target machine(s), cached pages may be broken by this, so they will need to be refreshed.
+or similar commands. If you are precompiling assets on the target machine(s), cached pages may be broken by this, so they will need to be refreshed.
2. You can change something in a different locale file.
3. Finally, you can change `config.assets.version`.
**Note:** See issue [#213](https://github.com/fnando/i18n-js/issues/213) for more details and discussion of this issue.
### Translations in JS are not updated when Sprockets not loaded before this gem
The "rails engine" declaration will try to detect existence of "sprockets" before adding the initailizer
-If sprockets is loaded after this gem, the preprocessor for
+If sprockets is loaded after this gem, the preprocessor for
making JS translations file cache to depend on content of locale files will not be hooked.
-So ensure sprockets is loaded before this gem like moving entry of sprockets in Gemfile or adding "require" statements for sprockets somewhere.
+So ensure sprockets is loaded before this gem by moving the entry of sprockets in the Gemfile or adding "require" statements for sprockets somewhere.
**Note:** See issue [#404](https://github.com/fnando/i18n-js/issues/404) for more details and discussion of this issue.
### JS `I18n.toCurrency` & `I18n.toNumber` cannot handle large integers