i18next: Revert some changes, as es/pt/pt-PT aren't mixed up (yet)

This commit is contained in:
Samantaz Fox 2023-10-07 19:12:17 +02:00
parent 32310b7c9f
commit f26c995344
No known key found for this signature in database
GPG Key ID: F42821059186176E
2 changed files with 24 additions and 22 deletions

View File

@ -17,7 +17,7 @@ FORM_TESTS = {
"cy" => I18next::Plurals::PluralForms::Special_Welsh, "cy" => I18next::Plurals::PluralForms::Special_Welsh,
"fr" => I18next::Plurals::PluralForms::Special_French_Portuguese, "fr" => I18next::Plurals::PluralForms::Special_French_Portuguese,
"en" => I18next::Plurals::PluralForms::Single_not_one, "en" => I18next::Plurals::PluralForms::Single_not_one,
"es" => I18next::Plurals::PluralForms::Special_Spanish_Italian, "es" => I18next::Plurals::PluralForms::Single_not_one,
"ga" => I18next::Plurals::PluralForms::Special_Irish, "ga" => I18next::Plurals::PluralForms::Special_Irish,
"gd" => I18next::Plurals::PluralForms::Special_Scottish_Gaelic, "gd" => I18next::Plurals::PluralForms::Special_Scottish_Gaelic,
"he" => I18next::Plurals::PluralForms::Special_Hebrew, "he" => I18next::Plurals::PluralForms::Special_Hebrew,
@ -33,8 +33,8 @@ FORM_TESTS = {
"mt" => I18next::Plurals::PluralForms::Special_Maltese, "mt" => I18next::Plurals::PluralForms::Special_Maltese,
"or" => I18next::Plurals::PluralForms::Special_Odia, "or" => I18next::Plurals::PluralForms::Special_Odia,
"pl" => I18next::Plurals::PluralForms::Special_Polish_Kashubian, "pl" => I18next::Plurals::PluralForms::Special_Polish_Kashubian,
"pt" => I18next::Plurals::PluralForms::Special_French_Portuguese, "pt" => I18next::Plurals::PluralForms::Single_gt_one,
"pt-PT" => I18next::Plurals::PluralForms::Special_French_Portuguese, "pt-BR" => I18next::Plurals::PluralForms::Special_French_Portuguese,
"ro" => I18next::Plurals::PluralForms::Special_Romanian, "ro" => I18next::Plurals::PluralForms::Special_Romanian,
"sk" => I18next::Plurals::PluralForms::Special_Czech_Slovak, "sk" => I18next::Plurals::PluralForms::Special_Czech_Slovak,
"sl" => I18next::Plurals::PluralForms::Special_Slovenian, "sl" => I18next::Plurals::PluralForms::Special_Slovenian,
@ -77,10 +77,10 @@ SUFFIX_TESTS = {
{num: 10, suffix: "_plural"}, {num: 10, suffix: "_plural"},
], ],
"es" => [ "es" => [
{num: 0, suffix: "_2"}, {num: 0, suffix: "_plural"},
{num: 1, suffix: "_0"}, {num: 1, suffix: ""},
{num: 10, suffix: "_2"}, {num: 10, suffix: "_plural"},
{num: 6_000_000, suffix: "_1"}, {num: 6_000_000, suffix: "_plural"},
], ],
"fr" => [ "fr" => [
{num: 0, suffix: "_0"}, {num: 0, suffix: "_0"},
@ -166,7 +166,7 @@ SUFFIX_TESTS = {
{num: 1, suffix: "_0"}, {num: 1, suffix: "_0"},
{num: 5, suffix: "_2"}, {num: 5, suffix: "_2"},
], ],
"pt" => [ "pt-BR" => [
{num: 0, suffix: "_0"}, {num: 0, suffix: "_0"},
{num: 1, suffix: "_0"}, {num: 1, suffix: "_0"},
{num: 10, suffix: "_2"}, {num: 10, suffix: "_2"},
@ -174,11 +174,10 @@ SUFFIX_TESTS = {
{num: 9_000_000, suffix: "_1"}, {num: 9_000_000, suffix: "_1"},
], ],
"pt-PT" => [ "pt-PT" => [
{num: 0, suffix: "_0"}, {num: 0, suffix: ""},
{num: 1, suffix: "_0"}, {num: 1, suffix: ""},
{num: 10, suffix: "_2"}, {num: 10, suffix: "_plural"},
{num: 42, suffix: "_2"}, {num: 9_000_000, suffix: "_plural"},
{num: 9_000_000, suffix: "_1"},
], ],
"ro" => [ "ro" => [
{num: 0, suffix: "_1"}, {num: 0, suffix: "_1"},

View File

@ -37,6 +37,8 @@ module I18next::Plurals
Special_Odia = 23 Special_Odia = 23
# Mixed v3/v4 rules in Weblate # Mixed v3/v4 rules in Weblate
# `es`, `pt` and `pt-PT` doesn't seem to have been refreshed
# by weblate yet, but I suspect it will happen one day.
# See: https://github.com/translate/translate/issues/4873 # See: https://github.com/translate/translate/issues/4873
Special_French_Portuguese Special_French_Portuguese
Special_Hungarian_Serbian Special_Hungarian_Serbian
@ -46,11 +48,11 @@ module I18next::Plurals
private PLURAL_SETS = { private PLURAL_SETS = {
PluralForms::Single_gt_one => [ PluralForms::Single_gt_one => [
"ach", "ak", "am", "arn", "br", "fil", "gun", "ln", "mfe", "mg", "ach", "ak", "am", "arn", "br", "fil", "gun", "ln", "mfe", "mg",
"mi", "oc", "tg", "tl", "ti", "tr", "uz", "wa", "mi", "oc", "pt", "tg", "tl", "ti", "tr", "uz", "wa",
], ],
PluralForms::Single_not_one => [ PluralForms::Single_not_one => [
"af", "an", "ast", "az", "bg", "bn", "ca", "da", "de", "dev", "el", "en", "af", "an", "ast", "az", "bg", "bn", "ca", "da", "de", "dev", "el", "en",
"eo", "et", "eu", "fi", "fo", "fur", "fy", "gl", "gu", "ha", "hi", "eo", "es", "et", "eu", "fi", "fo", "fur", "fy", "gl", "gu", "ha", "hi",
"hu", "hy", "ia", "kk", "kn", "ku", "lb", "mai", "ml", "mn", "mr", "hu", "hy", "ia", "kk", "kn", "ku", "lb", "mai", "ml", "mn", "mr",
"nah", "nap", "nb", "ne", "nl", "nn", "no", "nso", "pa", "pap", "pms", "nah", "nap", "nb", "ne", "nl", "nn", "no", "nso", "pa", "pap", "pms",
"ps", "rm", "sco", "se", "si", "so", "son", "sq", "sv", "sw", "ps", "rm", "sco", "se", "si", "so", "son", "sq", "sv", "sw",
@ -88,12 +90,11 @@ module I18next::Plurals
"sk" => PluralForms::Special_Czech_Slovak, "sk" => PluralForms::Special_Czech_Slovak,
"sl" => PluralForms::Special_Slovenian, "sl" => PluralForms::Special_Slovenian,
# Mixed v3/v4 rules # Mixed v3/v4 rules
"es" => PluralForms::Special_Spanish_Italian, "fr" => PluralForms::Special_French_Portuguese,
"fr" => PluralForms::Special_French_Portuguese, "hr" => PluralForms::Special_Hungarian_Serbian,
"hr" => PluralForms::Special_Hungarian_Serbian, "it" => PluralForms::Special_Spanish_Italian,
"it" => PluralForms::Special_Spanish_Italian, "pt-BR" => PluralForms::Special_French_Portuguese,
"pt" => PluralForms::Special_French_Portuguese, "sr" => PluralForms::Special_Hungarian_Serbian,
"sr" => PluralForms::Special_Hungarian_Serbian,
} }
# These are the v1 and v2 compatible suffixes. # These are the v1 and v2 compatible suffixes.
@ -164,7 +165,9 @@ module I18next::Plurals
def get_plural_form(locale : String) : PluralForms def get_plural_form(locale : String) : PluralForms
# Extract the ISO 639-1 or 639-2 code from an RFC 5646 language code # Extract the ISO 639-1 or 639-2 code from an RFC 5646 language code
locale = locale.split('-')[0] if !locale.matches?(/^pt-BR$/)
locale = locale.split('-')[0]
end
return self.forms[locale] if self.forms[locale]? return self.forms[locale] if self.forms[locale]?