-
-
Save radar/c74cadff6dee7988f764536d667f44df to your computer and use it in GitHub Desktop.
Illustrating i18n issue
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
source 'https://rubygems.org' | |
gem "pry" | |
gem 'i18n', github: "svenfuchs/i18n", branch: "173-reset-load-path" | |
gem "rspec" |
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
GIT | |
remote: git://github.com/svenfuchs/i18n.git | |
revision: e711e7921e58637ba03ebeb8990285c415c4c0b5 | |
branch: 173-reset-load-path | |
specs: | |
i18n (0.7.0) | |
GEM | |
remote: https://rubygems.org/ | |
specs: | |
coderay (1.1.1) | |
diff-lcs (1.2.5) | |
method_source (0.8.2) | |
pry (0.10.4) | |
coderay (~> 1.1.0) | |
method_source (~> 0.8.1) | |
slop (~> 3.4) | |
rspec (3.5.0) | |
rspec-core (~> 3.5.0) | |
rspec-expectations (~> 3.5.0) | |
rspec-mocks (~> 3.5.0) | |
rspec-core (3.5.4) | |
rspec-support (~> 3.5.0) | |
rspec-expectations (3.5.0) | |
diff-lcs (>= 1.2.0, < 2.0) | |
rspec-support (~> 3.5.0) | |
rspec-mocks (3.5.0) | |
diff-lcs (>= 1.2.0, < 2.0) | |
rspec-support (~> 3.5.0) | |
rspec-support (3.5.0) | |
slop (3.6.0) | |
PLATFORMS | |
ruby | |
DEPENDENCIES | |
i18n! | |
pry | |
rspec | |
BUNDLED WITH | |
1.13.5 |
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 '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 | |
expect(I18n.t("hello")).to eq "Hello world" | |
end | |
it "should fail if a translation is not found" do | |
puts "Translation fail" | |
expect(I18n.t('test')).to eq "translation missing: en.test" | |
end | |
end |
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 'rspec' | |
require 'i18n' | |
describe "I18n" do | |
it "should fail if a translation is not found" do | |
puts "Translation fail" | |
expect {I18n.t('test') }.to raise_error(I18n::InvalidLocale) | |
end | |
it "should translate hello to english" do | |
I18n.load_path += [Dir.pwd + "/en.yml"] | |
puts "Translate English" | |
I18n.locale = :en | |
expect(I18n.t("hello")).to eq "Hello world" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment