ember-cli-zanata
An addon to work with the Zanata API.
This is built to work together with ember-l10n.
Installation
ember install ember-cli-zanata
Enter your API data in the generated config/zanata.js
file.
Usage
This addons provides a few commands to use:
ember zanata:push
: Push your updated to Zanataember zanata:pull
: Pull a given version from Zanataember zanata:version-create
: Create a new version for a projectember zanata:version-info
: List information for a given version of a projectember zanata:version-stats
: List translation stats for a given version of a projectember zanata:project-info
: List basic information (like latest version) for a projectember zanata:project-list
: List all projects from Zanata
For all of these commands, you can run help
to see all available parameters, e.g. ember help zanata:push
.
Commands
push
Pull translation data from Zanata. This can pull translation files, source files, or both. Don't forget to specify a version & project to pull from!
You'll also need to specify the list of locales to pull.
It is recommended to put those (along with the project-id) in the config/zanata.js
file.
- Push all files:
ember zanata:push
- Push translation files only:
ember zanata:push --update-type=trans
- Push source files only:
ember zanata:push --update-type=source
Note that the Zanata API is a bit flaky. Because of this, this will try to push a few times - by default, 4 times. Only if it fails 4 times, will it error out.
pull
Pull translation data from Zanata. This can pull translation files, source files, or both. Don't forget to specify a version & project to pull from!
You'll also need to specify the list of locales to pull.
It is recommended to put those (along with the project-id) in the config/zanata.js
file.
- Pull translation files only:
ember zanata:pull
- Pull all files:
ember zanata:pull --update-type=both
- Pull source files only:
ember zanata:pull --update-type=source
version-create
Create a new version for a project.
ember zanata:version-create --version="XXX"
By default, it will push all files (sources & translations!) after successfully creating a new version. You can deactivate that behaviour like this:
ember zanata:version-create --version="XXX" --update-if-new=false
Additionally, if the version you are trying to create already exists, it will throw an error. You can supress that with:
ember zanata:version-create --version="XXX" -resolve-if-exists=true
This will then just print out a message that the version already exists, but exit with a success code.
version-stats
Show translation stats for a version of a project.
ember zanata:version-stats --version="XXX"
Will print something like this:
Translation progress
version-info
Show information for a version of a project.
This is mainly the available locales.
ember zanata:version-info --version="XXX"
Will print something like this:
Version 1.0.10
project-info
Display information for a given project.
ember zanata:project-info --project-id="XXX"
Will output something like:
Project my-project was successfully loadedProject name: My ProjectLatest version: 1.0.10
project-list
Display a list of all active projects available.
ember zanata:project-list
Will output something like:
2 active projects were found:My Project Other Project
Handling versions
Instead of specifying an actual version, you can also provide current
, which will use the version from the package.json
file.
Handling special locales
Sometimes, you might have locales that are called differently on Zanata than in your app.
For example, in Zanata you might have zh-Hans
, whereas it might be called zh_CN
in your app.
For this, you can provide a special function in your Zanata config:
// config/zanata.jsmodule { return // other config { // From your app to Zanata, e.g. zh_CN --> zh-Hans return locale; } { // From Zanata to your app, e.g. zh-Hans --> zh_CN return locale; } ;};
License
This project is licensed under the MIT License.