Skip to content

A platform for community discussion. Free, open, simple.

FIX: incorrect Breton plural rule logic operator (#37545)

Sam2e3d01ae0bb8
diff --git a/config/locales/plurals.rb b/config/locales/plurals.rb
index 2dcd6aff486..d179e168930 100644
--- a/config/locales/plurals.rb
+++ b/config/locales/plurals.rb
@@ -227,7 +227,7 @@
(
((n.to_f % 100) % 1).zero? &&
(
- !(10..19).include?(n.to_f % 100) || !(70..79).include?(n.to_f % 100) ||
+ !(10..19).include?(n.to_f % 100) && !(70..79).include?(n.to_f % 100) &&
!(90..99).include?(n.to_f % 100)
)
)
diff --git a/spec/lib/i18n/breton_plural_rule_spec.rb b/spec/lib/i18n/breton_plural_rule_spec.rb
new file mode 100644
index 00000000000..3659cd7c6e2
--- /dev/null
+++ b/spec/lib/i18n/breton_plural_rule_spec.rb
@@ -0,0 +1,39 @@
+# frozen_string_literal: true
+
+RSpec.describe "Breton plural rules", type: :integration do # rubocop:disable RSpec/DescribeClass
+ let(:br_plural_rule) do
+ plurals = eval(File.read(Rails.root.join("config/locales/plurals.rb"))) # rubocop:disable Security/Eval
+ plurals[:br][:i18n][:plural][:rule]
+ end
+
+ # Per CLDR: https://unicode.org/cldr/charts/45/supplemental/language_plural_rules.html
+ # few: n % 10 = 3..4,9 and n % 100 != 10..19,70..79,90..99
+ describe ":few category" do
+ it "returns :few for n % 10 in 3,4,9 when n % 100 not in excluded ranges" do
+ [3, 4, 9, 23, 24, 29, 43, 44, 49, 103, 104, 109].each do |n|
+ expect(br_plural_rule.call(n)).to eq(:few), "Expected #{n} to be :few"
+ end
+ end
+
+ it "returns :other for n % 10 in 3,4,9 when n % 100 IS in 10..19" do
+ [13, 14, 19].each do |n|
+ expect(br_plural_rule.call(n)).to eq(:other),
+ "Expected #{n} to be :other (n % 100 in 10..19)"
+ end
+ end
+
+ it "returns :other for n % 10 in 3,4,9 when n % 100 IS in 70..79" do
+ [73, 74, 79].each do |n|
+ expect(br_plural_rule.call(n)).to eq(:other),
+ "Expected #{n} to be :other (n % 100 in 70..79)"
+ end
+ end
+
+ it "returns :other for n % 10 in 3,4,9 when n % 100 IS in 90..99" do
+ [93, 94, 99].each do |n|
+ expect(br_plural_rule.call(n)).to eq(:other),
+ "Expected #{n} to be :other (n % 100 in 90..99)"
+ end
+ end
+ end
+end