Using as Gem:
Using as plugin:
gem 'fast_gettext', '>=0.4.8'
Add "gettext" if you want to find translations or build .mo files
Add "ruby_parser" if you want to find translations inside haml/slim files
gem 'gettext', '>=3.0.2', :require => false, :group => :development gem 'ruby_parser', :require => false, :group => :development
This will also create the locale directory (where the translations are being stored)
where XX is the ISO 639-1 2-letter code for the language you want to create.
for e.g. en_US, de_DE
To find any strings marked for translation.
run rake gettext:store_model_attributes
To parse the database for columns that can be translated
Add fast_gettext settings as follows:
# config/initializers/fast_gettext.rb FastGettext.add_text_domain 'app', :path => 'locale', :type => :po FastGettext.default_available_locales = ['en','de'] #all you want to allow FastGettext.default_text_domain = 'app'
Option: Using .po files
FastGettext.add_text_domain 'app', :path => 'locale', :type => :po
Option: Using .po/.mo files
FastGettext.add_text_domain 'app', :path => 'locale' run rake gettext:pack to write binary GetText .mo files
Performance is almost the same for all backends since translations are cached after first use.
What are POT/PO/MO files?
POT – Portable Object Template.
This is the file that you get when you extract texts from the application.
Normally, you send this file to your translators.
PO – Portable Object.
This is the file that you receive back from the translators.
It’s a text file that includes the original texts and the translations.
MO – Machine Object.
The MO file includes the exact same contents as PO file.
The two files differ in their format.
While a PO file is a text file and is easy for humans to read,
MO files are compiled and are easy for computers to read.
Your web server will use the MO file to display the translations.
<div class='pagesubtitle'><%= _('lbl|shipping_address') %></div>
add translation for _('lbl|shipping_address') in locales
msgstr "Add new Shipping Address"
Subscribe to Engineering At Kiprosh
Get the latest posts delivered right to your inbox