diff --git a/PLURALS_DIFF.md b/PLURALS_DIFF.md index ed8827c27..db0dcf5be 100644 --- a/PLURALS_DIFF.md +++ b/PLURALS_DIFF.md @@ -411,7 +411,7 @@ The Plurals column lists data in languages.csv which is used in Weblate | ljp | Lampung Api | nplurals=2; plural=n != 1; | | | | | | lki | Laki | nplurals=2; plural=n != 1; | | | | | | lkt | Lakota | nplurals=1; plural=0; | ✔ | | | | -| lld | Ladin | nplurals=2; plural=(n == 1) ? 0 : ((n != 0 && n % 1000000 == 0) ? 1 : 2); | ✔ | | | | +| lld | Ladin | nplurals=3; plural=(n == 1) ? 0 : ((n != 0 && n % 1000000 == 0) ? 1 : 2); | ✔ | | | | | lmn | Lambadi | nplurals=2; plural=n != 1; | | | | | | lmo | Lombard | nplurals=2; plural=n != 1; | | | | | | ln | Lingala | nplurals=2; plural=n > 1; | ✔ | | ✔ | ✔ | @@ -602,7 +602,7 @@ The Plurals column lists data in languages.csv which is used in Weblate | sat | Santali | nplurals=3; plural=n == 1 ? 0 : n == 2 ? 1 : 2; | ✔ | | nplurals=2; plural=(n != 1); | nplurals=2; plural=(n != 1); | | sc | Sardinian | nplurals=2; plural=n != 1; | ✔ | | | | | sck | Sadri | nplurals=2; plural=n != 1; | | | | | -| scn | Sicilian | nplurals=2; plural=(n == 1) ? 0 : ((n != 0 && n % 1000000 == 0) ? 1 : 2); | ✔ | | | nplurals=2; plural=(n != 1); | +| scn | Sicilian | nplurals=3; plural=(n == 1) ? 0 : ((n != 0 && n % 1000000 == 0) ? 1 : 2); | ✔ | | | nplurals=2; plural=(n != 1); | | sco | Scots | nplurals=2; plural=n != 1; | | | ✔ | ✔ | | sd | Sindhi | nplurals=2; plural=n != 1; | ✔ | | ✔ | ✔ | | sdh | Kurdish (Southern) | nplurals=2; plural=n != 1; | ✔ | | | | diff --git a/extraplurals.csv b/extraplurals.csv index 50174b024..78f34c701 100644 --- a/extraplurals.csv +++ b/extraplurals.csv @@ -20,3 +20,4 @@ lv,Latvian,3,(n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n%100<10 || n%100>=20) ? 1 se,Sami (Northern),2,(n != 1) sl,Slovenian,4,(n%100==1 ? 1 : n%100==2 ? 2 : n%100==3 || n%100==4 ? 3 : 0) ro_MD,Moldavian,3,(n == 1) ? 0 : ((n == 0 || n != 1 && n % 100 >= 1 && n % 100 <= 19) ? 1 : 2) +scn,Sicilian,2,n != 1 diff --git a/languages.csv b/languages.csv index 2efee7f43..3c4584f58 100644 --- a/languages.csv +++ b/languages.csv @@ -405,7 +405,7 @@ lij,Ligurian,2,n != 1 ljp,Lampung Api,2,n != 1 lki,Laki,2,n != 1 lkt,Lakota,1,0 -lld,Ladin,2,(n == 1) ? 0 : ((n != 0 && n % 1000000 == 0) ? 1 : 2) +lld,Ladin,3,(n == 1) ? 0 : ((n != 0 && n % 1000000 == 0) ? 1 : 2) lmn,Lambadi,2,n != 1 lmo,Lombard,2,n != 1 ln,Lingala,2,n > 1 @@ -596,7 +596,7 @@ sas,Sasak,2,n != 1 sat,Santali,3,n == 1 ? 0 : n == 2 ? 1 : 2 sc,Sardinian,2,n != 1 sck,Sadri,2,n != 1 -scn,Sicilian,2,(n == 1) ? 0 : ((n != 0 && n % 1000000 == 0) ? 1 : 2) +scn,Sicilian,3,(n == 1) ? 0 : ((n != 0 && n % 1000000 == 0) ? 1 : 2) sco,Scots,2,n != 1 sd,Sindhi,2,n != 1 sdh,Kurdish (Southern),2,n != 1 diff --git a/scripts/lint b/scripts/lint index efcb96806..1c69ee80d 100755 --- a/scripts/lint +++ b/scripts/lint @@ -5,6 +5,8 @@ # SPDX-License-Identifier: MIT import csv +from gettext import c2py +from itertools import chain def parse_csv(name): @@ -59,3 +61,20 @@ for match in matching: raise ValueError( f"Mismatching plural form for {match}: {plural_our!r} != {plural_cldr!r}" ) + + +# Validate plural count +for code, _name, plural_count, plural_formula in languages.values(): + plural = c2py(plural_formula) + # Get maximal plural + calculated = ( + max( + plural(x) + for x in chain(range(-10, 200), [1000, 10000, 100000, 1000000, 10000000]) + ) + + 1 + ) + if calculated != int(plural_count): + raise ValueError( + f"Mismatching plural count for {code}: {plural_count} != {calculated}" + ) diff --git a/weblate_language_data/languages.py b/weblate_language_data/languages.py index 65079904a..cab79b790 100644 --- a/weblate_language_data/languages.py +++ b/weblate_language_data/languages.py @@ -3676,7 +3676,7 @@ # variant of the language. It could contain a region, age (Old, Middle, ...) # or other variant. _("Ladin"), - 2, + 3, "(n == 1) ? 0 : ((n != 0 && n % 1000000 == 0) ? 1 : 2)", ), ( @@ -5395,7 +5395,7 @@ # variant of the language. It could contain a region, age (Old, Middle, ...) # or other variant. _("Sicilian"), - 2, + 3, "(n == 1) ? 0 : ((n != 0 && n % 1000000 == 0) ? 1 : 2)", ), ( diff --git a/weblate_language_data/plurals.py b/weblate_language_data/plurals.py index b38d46d07..2b85e364a 100644 --- a/weblate_language_data/plurals.py +++ b/weblate_language_data/plurals.py @@ -205,6 +205,15 @@ 3, "(n == 1) ? 0 : ((n == 0 || n != 1 && n % 100 >= 1 && n % 100 <= 19) ? 1 : 2)", ), + ( + "scn", + # Translators: Language name for ISO code "scn". The parenthesis clarifies + # variant of the language. It could contain a region, age (Old, Middle, ...) + # or other variant. + _("Sicilian"), + 2, + "n != 1", + ), ) CLDRPLURALS = ( @@ -289,15 +298,6 @@ 3, "(n == 1) ? 0 : ((n != 0 && n % 1000000 == 0) ? 1 : 2)", ), - ( - "lld", - # Translators: Language name for ISO code "lld". The parenthesis clarifies - # variant of the language. It could contain a region, age (Old, Middle, ...) - # or other variant. - _("Ladin"), - 3, - "(n == 1) ? 0 : ((n != 0 && n % 1000000 == 0) ? 1 : 2)", - ), ( "mt", # Translators: Language name for ISO code "mt". The parenthesis clarifies @@ -334,15 +334,6 @@ 3, "(n == 1) ? 0 : ((n != 0 && n % 1000000 == 0) ? 1 : 2)", ), - ( - "scn", - # Translators: Language name for ISO code "scn". The parenthesis clarifies - # variant of the language. It could contain a region, age (Old, Middle, ...) - # or other variant. - _("Sicilian"), - 3, - "(n == 1) ? 0 : ((n != 0 && n % 1000000 == 0) ? 1 : 2)", - ), ) QTPLURALS = (