Using as Gem:

gem 'gettext_i18n_rails'

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

Rakes:

rake gettext:add_language[XX]

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

rake gettext:find 

To find any strings marked for translation.

Optional:

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.

Application example:

<div class='pagesubtitle'><%= _('lbl|shipping_address')  %></div>

add translation for _('lbl|shipping_address') in locales

in locale/en_US/app.po
msgid "lbl|shipping_address"
msgstr "Add new Shipping Address"

in locale/de_DE/app.po
msgid "lbl|shipping_address"
msgstr "Auftragsspez.Adresse"

Reference:

Fastgettext

gettext_i18n_rails

Benchmark performance for Fastgettext