Overview
Rake task which creates translated locales files of a rails project from source locales. Translations are ‘bulk’ translations from google, and might be reviewed but that’s a easy first step. Create your locales files with your own language and run the task with targeted languages. It uses the gem ‘easy_translator’ which use google translations api.
Usage
rake i18n:translate['en','fr;es'].
Separate targets languages symbols with semicolons. /!\ Don’t put space after the coma for rake tasks parameters.
With no additional argument, it will translate and create locales for all your source locales. If you want to just do the work with only one locale source, pass an additional path to file source argument to rake tasks :
rake i18n:translate['en','fr;es','config/locales/user/en.yml'].
Convention
The source locale is supposed to be named <lang>.yml where lang is the language symbol (fr, en , es … and so on)
Example
-
config
-
locales
-
models
-
user
-
en.yml
-
book
-
en.yml
Will generate :
-
config
-
locales
-
models
-
user
-
en.yml
-
fr.yml
-
es.yml
-
book
-
en.yml
-
fr.yml
-
es.yml
Dependencies
-
rake
-
easy_translator
TO-DOs
Add options to be more flexible ; ie pass a translator lambda to use other translator.
Issues
Sometimes phrases with interpolations are not double quoted