https://github.com/cap32/neo-json-i18n
Translate json files over google translate
https://github.com/cap32/neo-json-i18n
cli i18n json nodejs translate
Last synced: 2 months ago
JSON representation
Translate json files over google translate
- Host: GitHub
- URL: https://github.com/cap32/neo-json-i18n
- Owner: Cap32
- License: mit
- Created: 2018-02-28T17:33:09.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-04-07T02:49:31.000Z (about 8 years ago)
- Last Synced: 2025-02-28T09:50:31.795Z (over 1 year ago)
- Topics: cli, i18n, json, nodejs, translate
- Language: JavaScript
- Homepage:
- Size: 330 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# neo-json-i18n
[](https://circleci.com/gh/Cap32/neo-json-i18n)
[](https://travis-ci.org/Cap32/neo-json-i18n)
[](https://ci.appveyor.com/project/Cap32/neo-json-i18n)
[](https://coveralls.io/github/Cap32/neo-json-i18n?branch=master)
[](http://makeapullrequest.com)
[](https://github.com/Cap32/neo-json-i18n/blob/master/LICENSE.md)
Translate json files over google translate
## Installation
#### Via yarn
```shell
$ yarn global add neo-json-i18n
```
#### Via npm
```shell
$ npm install -g neo-json-i18n
```
## CLI Usage
```txt
neo-json-i18n [options]
Translate json files over google translate
Positionals:
src Source file [string]
Options:
--config, -c Configuration file. Defaults to "i18nconfig.json"
[string]
--output, -o Output directory [string]
--srcLang, -L Src language [string] [default: "auto"]
--lang, -l Target languages [array] [default: ["en"]]
--pattern, -p Output file name pattern
[string] [default: "%name_%lang.%ext"]
--cwd, -d Current working directory
[string] [default: "/Users/webber/www/node/neo-json-i18n"]
--spaces, -s JSON format spaces [string] [default: " "]
--help Show help [boolean]
--version Show version number [boolean]
```
#### Notes
* `pattern` supports these placeholders:
* `%name`: file base name
* `%lang`: output language
* `%ext`: file extension name
* Language supports: [plesase checkout here](/Languages.md)
#### Example
**~/my/repo/dict.json**
```json
{ "film": "Star Wars" }
```
Open terminal, and run:
```shell
$ cd ~/my/repo/
$ neo-json-i18n dict.json --lang zh-cn,ja
```
It would create `dict_zh-cn.json` and `dict_ja.json` file as result
**~/my/repo/dict_zh-cn.json**
```json
{ "film": "星球大战" }
```
**~/my/repo/dict_ja.json**
```json
{ "film": "スターウォーズ" }
```
## Node Module API Usage
```js
import jsonI18n from "neo-json-i18n";
const json = { film: "Star Wars" };
jsonI18n(json, { lang: ["zh-cn", "ja"] })
.then(res => console.log(res))
.catch(err => console.error(err));
/*
* { 'zh-cn': { film: '星球大战' }, 'ja': { film: 'スターウォーズ' } }
*/
```
## License
MIT