ignore_locales is an array of symbols, an array of strings, a symbol or a string of locales not to sync with Web Translate It. You usually don’t want to sync your master language files.

wti_id1 is the id of your master language file on Web Translate It. If you only have one language file, then only put this one in the configuration file.

config/locales/file1_[locale].yml is the name of your language file on your project. To keep things simple, the gem makes the reasonable assumption that you differentiate your language files using the locale name. For example, you will have file1_en.yml for English, and file1_fr.yml for French. Replace en or fr by [locale] and the gem will update the files file1_en.yml and file1_fr.yml.

The gem also assume that you use the same locale name on your project and on Web Translate It. For example if you use the locale fr_FR on Web Translate It, then you should use fr_FR on your project.

Rake tasks provided

The gem provides 5 rake tasks.

rake trans:fetch:all

Fetch the latest translations for all your files for all languages defined in Web Translate It’s interface, except for the languages set in ignore_locales.

rake trans:fetch[fr_FR]

Fetch the latest translations for all the languages defined in Web Translate It’s interface. It takes the locale name as a parameter

rake trans:send[fr_FR]

Updates the latest translations for all your files in a specific locale defined in Web Translate It’s interface.

rake trans:config

Copy a translation.yml file to config/translation.yml if the file doesn’t exist.

rake trans:version

Display the gem version.

Automatically fetch new language files

This is useful for translators on development and staging environment: you get the strings as soon as they are translated on Web Translate It, but you probably don’t want this on production for performance and reliability reasons.

Rails 2.3 and newer

Use the rack middleware!

Before starting up anything, you need to have a rack middleware setup to assign the value of the current locale to
I18n.locale.
This is very much specific to your app, this is left as an exercise to the reader. You can inspire yourself from
Ryan Tomakyo’s locale.rb.
You can also find an example of a very simple middleware using the locale parameter in
[examples/locale.rb](http://github.com/AtelierConvivialite/webtranslateit/blob/master/examples/locale.rb).

The next step is to setup the autofetch middleware. Add in config/environments/development.rb and any other
environments you want to autofetch this line:

config.middleware.use "WebTranslateIt::AutoFetch"

Restart your application, load a page. You should see this in the logs:

Restart your application for the changes to take effect. You should see something like this in the logs:

Looking for fr translations...
Done. Response code: 304

That’s it!

Supported Rails Versions

The gem currently has been tested against the following version of Rails:

2.3.4

2.3.5

Please open a discussion on the support forum if you're using a version of Rails that is not listed above and the gem is not working properly.

What is Web Translate It anyway?

Web Translate It is a web-based software for translating websites and applications. Its API it affords you to translate on Web Translate It’s web interface and test your translations on your development or staging environment. This is really useful for translations to translate on a stable environment, while being able to test their work directly.

Take a look at the tour page and at our plans. We have a 10-day free trial, so you can give it a try for free.