Last active
December 16, 2015 07:28
-
-
Save chrishunt/5398444 to your computer and use it in GitHub Desktop.
i18n in Ruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
arabic: | |
hello: "مرحبا العالم!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
danish: | |
hello: "Hej Verden!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
en: | |
hello: "Hello World!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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