diff options
author | Louise Crow <louise.crow@gmail.com> | 2013-04-24 15:20:14 +0100 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2013-04-24 15:20:14 +0100 |
commit | 7195e67e525af76f264e278e22a2784040c45d46 (patch) | |
tree | 5825044ec29145b95b61fe781113b1046ca6c4ce /spec/lib/i18n_interpolation.rb | |
parent | 4929b1e738d15d2178e131701027ef20492599d9 (diff) | |
parent | d3aae5cc48c92473e06b2104bb9431305d5a92f0 (diff) |
Merge branch 'release/0.9'0.9
Conflicts:
locale/cs/app.po
locale/he_IL/app.po
locale/id/app.po
locale/it/app.po
locale/ro_RO/app.po
locale/uk/app.po
Diffstat (limited to 'spec/lib/i18n_interpolation.rb')
-rw-r--r-- | spec/lib/i18n_interpolation.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/spec/lib/i18n_interpolation.rb b/spec/lib/i18n_interpolation.rb index e8d046757..b07cf1e9a 100644 --- a/spec/lib/i18n_interpolation.rb +++ b/spec/lib/i18n_interpolation.rb @@ -12,7 +12,35 @@ describe "when using i18n" do it "should assume that simple translations are always html safe" do _("Hello").should be_html_safe end +end + +describe "n_" do + it "should return the translated singular" do + FastGettext.should_receive(:n_).with("Apple", "Apples", 1).and_return("Apfel") + n_("Apple", "Apples", 1).should == "Apfel" + end + + it "should return the translated plural" do + FastGettext.should_receive(:n_).with("Apple", "Apples", 3).and_return("Äpfel") + n_("Apple", "Apples", 3).should == "Äpfel" + end + it "should return the translated singular interpolated" do + FastGettext.should_receive(:n_).with("I eat {{count}} apple", "I eat {{count}} apples", 1). + and_return("Ich esse {{count}} Apfel") + n_("I eat {{count}} apple", "I eat {{count}} apples", 1, :count => 1).should == "Ich esse 1 Apfel" + end + + it "should return the translated plural interpolated" do + FastGettext.should_receive(:n_).with("I eat {{count}} apple", "I eat {{count}} apples", 3). + and_return("Ich esse {{count}} Äpfel") + n_("I eat {{count}} apple", "I eat {{count}} apples", 3, :count => 3).should == "Ich esse 3 Äpfel" + end + + it "should always be html safe when there is no interpolation" do + FastGettext.should_receive(:n_).with("Apple", "Apples", 1).and_return("Apfel") + n_("Apple", "Apples", 1).should be_html_safe + end end describe "gettext_interpolate" do |