Skip to content

Instantly share code, notes, and snippets.

@lynnfaraday
Last active November 9, 2016 21:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lynnfaraday/c64e2e4d9a3c91a8eac4592ff95b4968 to your computer and use it in GitHub Desktop.
Save lynnfaraday/c64e2e4d9a3c91a8eac4592ff95b4968 to your computer and use it in GitHub Desktop.
Illustrating i18n issue
en:
hello: "Hello world"
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
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