-
Automatically adds missing model translations
-
Uses Google Translate by default (you can use your own backend)
-
Marks auto translated data
To install Globalize3 Translator use:
gem install globalize3_translator
If you wish to override default configuration create config/initializers/globalize3.rb
Globalize::Translator.configure do |config| # automatically translate only to specified locales config.locales = [ :lt, :de ] # use custom translator backend config.backend = MyTranslatorBackend end
Example:
post = Post.new :title => "Dog" post.save! post.reload # should be "false" for current locale post.title.auto_translated? I18n.locale = :lt # should be "true" for other locale post.title.auto_translated?
Example:
class MyTranslatorBackend < Globalize::Translator::Backends::Abstract def translate(value, from_locale, to_locale) # should return translated value "test #{value}" end end
Globalize3 Translator uses extra boolean fields in translations table to track automatic translations (with suffix ‘_auto_translated’).
Globalize3 standard method “create_translation_table!” automatically adds <name>_auto_translated fields so you don’t have to worry about that for new tables.
If you want to add auto translated fields to existing translations table, you should do it manually in migration.
Example:
add_column :post_translations, :title_auto_translated, :boolean
Please send all patches or fixes as github pull requests. Preferably with tests.
Copyright © 2010 Laurynas Butkus, released under the MIT license