Skip to content

Commit

Permalink
add lineEndings to documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
jwbay committed Oct 23, 2016
1 parent 537e5c5 commit 0dd0908
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 26 deletions.
35 changes: 10 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ sync({
});
```

(or via CLI: `sync-i18n --files locales/*.json --primary en`)

resulting in:

```json
Expand Down Expand Up @@ -83,10 +81,12 @@ languages according to the [i18next suffix rules](http://i18next.com/docs/plural
This works on one folder at a time, but can deal with whatever the files glob returns. Files are
grouped into directories before processing starts. Folders without a 'primary' found are ignored.

## Node.js Usage
## Usage

`$ npm install i18next-json-sync --save-dev`

#### In node.js

```js
import sync from 'i18next-json-sync';
//or in ES5 world:
Expand All @@ -103,18 +103,20 @@ sync({
primary: 'en',
/** Language files to create if they don't exist, e.g. ['es, 'pt-BR', 'fr'] */
createResources: [],
/** Space value used for JSON.stringify */
space: 4
/** Space value used for JSON.stringify when writing JSON files to disk */
space: 4,
/** Line endings used when writing JSON files to disk. Either LF or CRLF */
lineEndings: 'LF'
})
```

## CLI Usage
#### CLI

It can be installed globally, but npm's [package.json scripts](https://docs.npmjs.com/misc/scripts) are a better fit.

```json
{
"name": "foo",
"name": "my-app",
"scripts": {
"i18n": "sync-i18n --files **/locales/*.json --primary en --languages es fr ja zh ko --space 2",
"check-i18n": "npm run i18n -- --check"
Expand All @@ -127,24 +129,7 @@ It can be installed globally, but npm's [package.json scripts](https://docs.npmj

Then use `npm run i18n` to sync on the filesystem and `npm run check-i18n` to validate.

Use `sync-i18n -h` to get help output:

```
Options:
-c, --check Audit files in memory instead of changing them on the
filesystem and throw an error if any changes would be made
[boolean]
-f, --files Glob pattern for the resource JSON files
-p, --primary Primary localization language. Other language files will be
changed to match
-l, --languages Language files to create if they don't exist [array]
-s, --space Space value used for JSON.stringify
-h, --help Show help [boolean]
Examples:
--files **/locales/*.json
--languages es fr pt-BR ja
```
All options are available via CLI. Use `-h` or `--help` to get help output.

## License

Expand Down
9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,14 @@
"keywords": [
"i18next",
"json",
"sync"
"sync",
"synchronize",
"plurals",
"pluralization",
"l10n",
"i18n",
"localization",
"internationalization"
],
"author": "justin.bay@outlook.com",
"license": "MIT",
Expand Down

0 comments on commit 0dd0908

Please sign in to comment.