Home

Awesome

R18n Rails API

Cirrus CI - Base Branch Build Status Codecov branch Code Climate Depfu License Gem

Rails I18n compatibility for R18n:

It is just a wrapper for R18n core library. See R18n documentation for more information.

How To

Rails Translations

You can use R18n::Loader::Rails to load translations from I18n.load_path:

i18n/en.yml:

en:
  posts:
    one: One post
    many: %{count} posts

example.rb:

require 'r18n-rails-api'

I18n.load_path = ['i18n/en.yml']
i18n = R18n::I18n.new('en', R18n::Loader::Rails)

i18n.posts(count: 5) #=> "5 posts"

Back-end

You can use R18n as a back-end for Rails I18n:

require 'r18n-rails-api'

R18n.set('en', 'path/to/translation')
I18n.backend = R18n::Backend.new

I18n.l Time.now, format: :full #=> "6th of December, 2009 22:44"
I18n.t :greeting, name: 'John' #=> "Hi, John"
I18n.t :users, count: 5        #=> "5 users"

R18n Features

License

R18n is licensed under the GNU Lesser General Public License version 3. You can read it in LICENSE file or in www.gnu.org/licenses/lgpl-3.0.html.

Author

Andrey “A.I.” Sitnik andrey@sitnik.ru