[i18n] Add irregular pluralizations #629
Labels
💻 aspect: code
Concerns the software code in the repository
✨ goal: improvement
Improvement to an existing user-facing feature
🟩 priority: low
Low priority and doesn't need to be rushed
🧱 stack: frontend
Related to the Nuxt frontend
Problem
Some languages have more than one plural noun form that correspond to different numbers. We need to set up the pluralization for languages other than Russian.
Description
Vue-i18n uses the pluralization config to select the correct form, and here is the example implementation for Russian:
https://github.com/WordPress/openverse-frontend/blob/0f784f4df9fdf4b460dab387f0877229420efebc/src/plugins/vue-i18n.js#L11-L30
This corresponds to the following config in the
.po
format:"pluralExpression": "(n % 10 == 1 && n % 100 != 11) ? 0 : ((n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 12 || n % 100 > 14)) ? 1 : 2)",
It is OK to create one PR per single locale group with the same pluralExpression, one from the following list:
Locales:
ar
, Algerian Arabicarq
, Moroccan Arabicary
bn_IN
, Bretonbre
, Persian (Afghanistan)fa_AF
, Persianfa_IR
, French (Belgium)fr_BE
, French (Canada)fr_CA
, French (France)fr_FR
, Arpitanfrp
, Borana-Arsi-Guji Oromogax
, Indonesianid_ID
, Kabylekab
, Lingalalin
, Maorimri
, Occitanoci
, Picardpcd
, Portuguese (Brazil)pt_BR
, Saraikiskr
, Tahitiantah
, Turkishtr_TR
, Turkmentuk
, Tamazight (Central Atlas)tzm
cor
cs_CZ
, Slovaksk_SK
cy
dsb
, Upper Sorbianhsb
, Slovenian `sl_SIga
gd
is_IS
', 'Macedonianmk_MK
lt_LT
lv
me_ME
pl_PL
ro_RO
szl
zgh
These locales use a single version, so probably don't need any pluralization set up?
art_xemoji
, Balochi Southernbcc
, Tibetanbo
, Dzongkhadzo
, Igboibo
, Japaneseja
, Georgianka_GE
, Kyrgyzkir
, Khmerkm
, Koreanko_KR
, Laolo
, Mauritian Creolemfe
, Malayms_MY
, Rohingyarhg
, Sundanesesu_ID
, Thaith
, Tigrinyatir
, Tatartt_RU
, Uzbekuz_UZ
, Vietnamesevi
, Wolofwol
, Chinese (China)zh_CN
, Chinese (Hong Kong)zh_HK
, Chinese (Singapore)zh_SG
, Chinese (Taiwan)zh_TW
These locales should use the same rules as Russian:
bel
, Ukrainianuk
, Serbiansr_RS
, Croatianhr
, Bosnianbs_BA
Additional context
To get the
.po
format pluralization rules, runpnpm run dev
. This should create asrc/locales/scripts/wp-locales.json
file, with an object with locale properties for all available locales. Only the locales with irregular plurals have the"pluralExpression"
property.Implementation
The text was updated successfully, but these errors were encountered: