Last active
November 9, 2016 21:31
-
-
Save lynnfaraday/c64e2e4d9a3c91a8eac4592ff95b4968 to your computer and use it in GitHub Desktop.
Illustrating i18n issue
This file contains hidden or 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 hidden or 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 'rspec' | |
require 'i18n' | |
describe "I18n" do | |
it "should translate hello to english" do | |
I18n.load_path << Dir.pwd + "/en.yml" | |
puts "Translate English" | |
I18n.locale = :en | |
I18n.t("hello").should eq "Hello world" | |
end | |
it "should fail if a translation is not found" do | |
puts "Translation fail" | |
I18n.t('test').should eq "translation missing: en.test" | |
end | |
end |
This file contains hidden or 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 'rspec' | |
require 'i18n' | |
describe "I18n" do | |
it "should fail if a translation is not found" do | |
puts "Translation fail" | |
I18n.t('test').should eq "translation missing: en.test" | |
end | |
it "should translate hello to english" do | |
I18n.load_path << Dir.pwd + "/en.yml" | |
puts "Translate English" | |
I18n.locale = :en | |
I18n.t("hello").should eq "Hello world" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment