README.md in i18n-js-3.3.0 vs README.md in i18n-js-3.4.0
- old
+ new
@@ -1,15 +1,18 @@
# I18n.js
[![Gem Version](http://img.shields.io/gem/v/i18n-js.svg?style=flat-square)](http://badge.fury.io/rb/i18n-js)
+[![npm](https://img.shields.io/npm/v/i18n-js.svg?style=flat-square)](https://www.npmjs.com/package/i18n-js)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](https://opensource.org/licenses/MIT)
[![Build Status](http://img.shields.io/travis/fnando/i18n-js.svg?style=flat-square)](https://travis-ci.org/fnando/i18n-js)
[![Coverage Status](http://img.shields.io/coveralls/fnando/i18n-js.svg?style=flat-square)](https://coveralls.io/r/fnando/i18n-js)
[![Gitter](https://img.shields.io/badge/gitter-join%20chat-1dce73.svg?style=flat-square)](https://gitter.im/fnando/i18n-js)
+> The above badges are generated by https://shields.io/
+
It's a small library to provide the Rails I18n translations on the JavaScript.
Features:
- Pluralization
@@ -241,9 +244,30 @@
```
MyNamespace.translations || (MyNamespace.translations = {});
MyNamespace.translations["en"] = { ... }
```
+
+
+### Adding a line at the beggining of the translations file (useful for imports)
+
+Setting the `prefix: "import I18n from 'i18n-js';\n"` option will add the line at the beggining of the resultant translation file.
+This can be useful to use this gem with the [i18n-js](https://www.npmjs.com/package/i18n-js) npm package, which is quite useful to use it with webpack.
+The user should provide the semi-colon and the newline character if needed.
+
+For example:
+
+```yaml
+translations:
+- file: "public/javascripts/i18n/translations.js"
+ prefix: "import I18n from 'i18n-js';\n"
+```
+
+will create:
+
+```
+import I18n from 'i18n-js';
+I18n.translations || (I18n.translations = {});
#### Pretty Print
Set the `pretty_print` option if you would like whitespace and indentation in your output file (default: false)