Skip to content

Instantly share code, notes, and snippets.

@chrishunt
Last active December 16, 2015 07:28
Show Gist options
  • Save chrishunt/5398444 to your computer and use it in GitHub Desktop.
Save chrishunt/5398444 to your computer and use it in GitHub Desktop.
i18n in Ruby
arabic:
hello: "مرحبا العالم!"
danish:
hello: "Hej Verden!"
en:
hello: "Hello World!"
require 'i18n'
I18n.load_path = Dir[ "#{Dir.pwd}/*.yml" ]
I18n.backend.load_translations
I18n.default_locale
#=> :en
I18n.t 'hello'
#=> "Hello World!"
I18n.locale = :danish
I18n.t 'hello'
#=> "Hej Verden!"
I18n.locale = :arabic
I18n.t 'hello'
#=> "مرحبا العالم!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment