NodeJS
The original i18n node module uses translations stored in the following format:
{
"Hello": "Hello",
"Hello %s, how are you today?": "Hello %s, how are you today?",
"weekend": "weekend",
"Hello %s, how are you today? How was your %s.": "Hello %s, how are you today? How was your %s.",
"Hi": "Hi",
"Howdy": "Howdy",
"%s cat": {
"one": "%s cat",
"other": "%s cats"
},
"There is one monkey in the %%s": {
"one": "There is one monkey in the %%s",
"other": "There are %d monkeys in the %%s"
},
"tree": "tree"
}
This format is supported by Transifex via JSON Key-Value.
In order to run the Transifex Client from NodeJS, you will need to use the child_process.execFile API.
The source file will be the foundation for setting up the Transifex Client, which lets you send and receive files over Transifex's REST API. In order to set up your Transifex Client configuration, you first need a project in Transifex.
After finishing all the steps above, follow the set of commands below to set up your repository configuration in a file called .tx/config. In this example, we named our project in Transifex mytxproject
.
$ git clone http://git.example.com/git/myapp.git
$ cd myapp
$ tx init
$ tx add \
--file-filter=config/locales/<lang>.json \
--type=JSON \
--organization=organization-1 \
--project=mytxproject \
--resource=default_json \
config/locales/en.json
You should commit the .tx/config
file to your repository so the next time you want to push new source content, you can simply use the following commands
$ cd myapp
$ tx push -s
To download translations once their are complete in Transifex, use:
$ cd myapp
$ tx pull -t -a
Community integrations
There are 2 community support projects:
Node Transifex via GitHub :: via npm
A simple bookmarklet that does the leg work to make ready a webpage of localization.
Updated about 2 years ago