-
-
Notifications
You must be signed in to change notification settings - Fork 411
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix regression introduced by b7f69f7
The count argument was being ignored in certain cases. Fixes #510
- Loading branch information
Showing
2 changed files
with
56 additions
and
1 deletion.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
require 'test_helper' | ||
|
||
class I18nBackendPluralizationScopeTest < I18n::TestCase | ||
class Backend < I18n::Backend::Simple | ||
include I18n::Backend::Pluralization | ||
include I18n::Backend::Fallbacks | ||
end | ||
|
||
def setup | ||
super | ||
I18n.default_locale = :'en' | ||
I18n.backend = Backend.new | ||
|
||
translations = { | ||
i18n: { | ||
plural: { | ||
keys: [:one, :other], | ||
rule: lambda { |n| n == 1 ? :one : :other }, | ||
} | ||
}, | ||
activerecord: { | ||
models: { | ||
my_model: { | ||
one: 'one model', | ||
other: 'more models', | ||
some_other_key: { | ||
key: 'value' | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
store_translations('en', translations) | ||
end | ||
|
||
test "pluralization picks :other for 2" do | ||
args = { | ||
scope: [:activerecord, :models], | ||
count: 2, | ||
default: ["My model"] | ||
} | ||
assert_equal 'more models', I18n.translate(:my_model, args) | ||
end | ||
|
||
test "pluralization picks :one for 1" do | ||
args = { | ||
scope: [:activerecord, :models], | ||
count: 1, | ||
default: ["My model"] | ||
} | ||
assert_equal 'one model', I18n.translate(:my_model, args) | ||
end | ||
|
||
end |