Homepage | RDoc | Example app | Report a bug | Support
web_translate_it
is a rubygem providing tools to sync your language files with Web Translate It, a web-based translation software.
This gem provides:
- a command-line executable
wti
, to sync your files between your computer/server and WebTranslateIt.com, - a synchronisation server to help your translation team update your language files from a web interface,
- a rack middleware you can use within your Rails app to automatically fetch new translations from Web Translate It.
These instructions are for Linux and Mac OS X system. Follow these instructions if you’re using Microsoft Windows.
gem install web_translate_it
At this point you should have the wti
executable working.
Now that the tool is installed, you’ll have to configure your project:
wti init
The tool will prompt for:
- your Web Translate It API key. You can find it in your project settings (where are the project settings?),
- where to save the configuration file (by default in
config/translations.yml
).
Execute wti --help
to see the usage:
Usage: wti <command> [options]+
The most commonly used wti commands are:
pull Pull target language file(s)
push Push master language file(s)
match Display matching of local files with File Manager
add Create and push a new master language file
addlocale Add a new locale to the project
server Start a synchronisation server
status Fetch and display project statistics
init Configure your project to sync
See `wti <command> --help` for more information on a specific command.
[options] are:
--config, -c <s>: Path to a translation.yml file (default:
config/translation.yml)
--version, -v: Print version and exit
--help, -h: Show this message
Append --help
for each command for more information. For instance:
$ wti push --help
Push master language file(s)
[options] are:
--locale, -l <s>: ISO code of locale(s) to push
--all, -a: Upload all files
--low-priority, -o: WTI will process this file with a low priority
--merge, -m: Force WTI to merge this file
--ignore-missing, -i: Force WTI to not obsolete missing strings
--label, -b <s>: Apply a label to the changes
--help, -h: Show this message
Command | Action |
---|---|
wti add path/to/master/file.po | Upload a new master language file |
wti add file1.po file2.po file3.xml | Create several master language files at once, by specifying each file |
wti add *.po | Create several master language files at once, by specifying an extension |
wti push | Update a master language file |
wti push -l fr | Update a target (French) language file |
wti push -l "fr en da sv" | Update several target language files at once (French, English, Danish, Swedish) |
wti push --all | Update all language files at once |
wti pull | Download target language files |
wti pull -l fr | Download a specific language file (French) |
wti pull --all | Download all language files, including source |
wti pull --force | Force pull (to bypass Web Translate It’s HTTP caching) |
wti addlocale fr | Add a new locale to the project |
wti addlocale fr da sv | Add several locales at once |
wti status | View project statistics |
It is sometimes useful to hook a command or a script before or after a push or a pull. One use-case would be to launch a build after pulling language files. You can do that by implementing hooks in your translation.yml
file.
There are 4 hooks:
before_pull
after_pull
before_push
after_push
Check the sample translation.yml
file for implementation.
wti
contains a server you can use to run a friendly web interface to sync your translations. It allows a translation team to refresh the language files on a staging server without asking the developers to manually wti pull
.
To get started, go to the directory of the application you want to sync and do:
wti server
By default, it starts an application on localhost on the port 4000. You will find the tool on http://localhost:4000
.
Should you need to use another host or port, you can use the -h
and -p
options. For example: wti server -p 1234
.
You may want to run some commands before or after syncing translations. You can use the hooks to do so. For instance, you could add the following in your translation.yml
file:
before_pull: "echo 'some unix command'"
after_pull: "touch tmp/restart.txt"
before_pull
and after_pull
are respectively executed before and after pulling language files.
Copyright (c) 2009-2011 Atelier Convivialité, released under the MIT License.