Skip to content

Commit

Permalink
Fixed bug with ngettext where it wouldn't find translations with keys…
Browse files Browse the repository at this point in the history
… having a dot in them.
  • Loading branch information
roidrage committed Dec 1, 2009
1 parent 1c8fcd3 commit 7362a43
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/i18n/helpers/gettext.rb
Expand Up @@ -40,7 +40,7 @@ def nsgettext(msgid, msgid_plural, n = 1, separator = '|')

scope, msgid = I18n::Gettext.extract_scope(msgid, separator)
default = { :one => msgid, :other => msgid_plural }
I18n.t(msgid, :default => default, :count => n, :scope => scope)
I18n.t(msgid, :default => default, :count => n, :scope => scope, :separator => separator)
end
alias ns_ nsgettext

Expand Down
5 changes: 5 additions & 0 deletions test/fixtures/locales/de.po
Expand Up @@ -65,3 +65,8 @@ msgid "Car|wheel"
msgid_plural "Car|wheels"
msgstr[0] "Rad"
msgstr[1] "Räder"

msgid "On %{count} wheel."
msgid_plural "On %{count} wheels."
msgstr[0] "Auf %{count} Achse."
msgstr[1] "Auf %{count} Achsen."
7 changes: 7 additions & 0 deletions test/gettext/backend_test.rb
Expand Up @@ -81,4 +81,11 @@ def test_pluralizes_namespaced_entry_with_alternative_syntax
assert_equal 'Rad', npgettext('Car', ['wheel', 'wheels'], 1)
assert_equal 'Räder', npgettext('Car', ['wheel', 'wheels'], 2)
end

def test_ngettextpluralizes_entry_with_dots
I18n.locale = :de
assert_equal 'Auf 1 Achse.', n_("On %{count} wheel.", "On %{count} wheels.", 1)
assert_equal 'Auf 2 Achsen.', n_("On %{count} wheel.", "On %{count} wheels.", 2)
end

end

0 comments on commit 7362a43

Please sign in to comment.