diff options
author | Louise Crow <louise.crow@gmail.com> | 2013-04-15 20:52:30 +0100 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2013-04-16 12:49:10 +0100 |
commit | f65ec8a97b3ff677201e8ebb1ddb3b9234374197 (patch) | |
tree | 13a5c50339106c3be264cb7d8c7de81004994702 /spec/lib/i18n_interpolation.rb | |
parent | 5843eabfab7085a4a53210fe71ebd37242b46e6e (diff) | |
parent | f6dd4d5f2a58b555ff11a08eb62c25de7be25b02 (diff) |
Merge branch 'feature/final-consistent-translation-interpolation' into develop
Conflicts:
app/models/outgoing_message.rb
app/views/general/search.rhtml
app/views/public_body/list.rhtml
app/views/public_body/show.rhtml
app/views/public_body/view_email.rhtml
app/views/request/_after_actions.rhtml
app/views/request/_followup.rhtml
app/views/request/_sidebar.rhtml
app/views/request/new.rhtml
app/views/request/select_authority.rhtml
app/views/request/upload_response.rhtml
locale/aln/app.po
locale/app.pot
locale/ar/app.po
locale/bs/app.po
locale/ca/app.po
locale/cs/app.po
locale/cy/app.po
locale/de/app.po
locale/en/app.po
locale/en_IE/app.po
locale/es/app.po
locale/eu/app.po
locale/fr/app.po
locale/gl/app.po
locale/hu_HU/app.po
locale/id/app.po
locale/nb_NO/app.po
locale/pt_BR/app.po
locale/ro_RO/app.po
locale/sl/app.po
locale/sq/app.po
locale/sr@latin/app.po
locale/tr/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 |