Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(i18n): add the plural forms each dashboard locale needs

Yudhi Armyndharis84d3350855d1
diff --git a/dashboard/scripts/check-i18n-parity.mjs b/dashboard/scripts/check-i18n-parity.mjs
index fbea80caf..b1fb0aed8 100644
--- a/dashboard/scripts/check-i18n-parity.mjs
+++ b/dashboard/scripts/check-i18n-parity.mjs
@@ -9,6 +9,10 @@
* `{{name}}`) silently breaks interpolation, which a key-presence check can't see.
* 3. UNTRANSLATED PROSE (warning): a long leaf value byte-identical to en.json is very likely still
* English — surfaced as a non-fatal drift signal (short coincidental matches are ignored).
+ * 4. PLURAL FORMS (hard fail): for every plural key in en.json (one with an `_other` variant), a
+ * locale carries a form for each category `Intl.PluralRules` gives its language. i18next falls
+ * back to the bare (singular) key for a missing category, so French without `_many` renders
+ * "1000000 abonné". The bare key covers `one`.
*
* Wire into CI with: `npm run i18n:check`
*/
@@ -66,6 +70,7 @@ function load(file) {
const referenceKeys = flatten(load(REFERENCE));
const referenceEntries = flattenEntries(load(REFERENCE));
+const pluralBases = [...referenceKeys].filter((k) => k.endsWith('_other')).map((k) => k.slice(0, -'_other'.length));
const localeFiles = readdirSync(LOCALES_DIR)
.filter((f) => f.endsWith('.json') && f !== REFERENCE)
.sort();
@@ -76,7 +81,12 @@ for (const file of localeFiles) {
const keys = flatten(load(file));
const entries = flattenEntries(load(file));
const missing = [...referenceKeys].filter((k) => !keys.has(k)).sort();
- const extra = [...keys].filter((k) => !referenceKeys.has(k)).sort();
+ const pluralCategories = new Intl.PluralRules(file.replace(/\.json$/, '')).resolvedOptions().pluralCategories;
+ const pluralForms = new Set(pluralBases.flatMap((base) => pluralCategories.map((c) => `${base}_${c}`)));
+ const missingPlurals = [...pluralForms]
+ .filter((k) => !keys.has(k) && !(k.endsWith('_one') && keys.has(k.slice(0, -'_one'.length))))
+ .sort();
+ const extra = [...keys].filter((k) => !referenceKeys.has(k) && !pluralForms.has(k)).sort();
const placeholderMismatches = [];
const untranslated = [];
@@ -104,6 +114,12 @@ for (const file of localeFiles) {
}
}
+ if (missingPlurals.length > 0) {
+ hasErrors = true;
+ console.error(`[FAIL] ${file}: missing ${missingPlurals.length} plural form(s) its language needs:`);
+ for (const k of missingPlurals) console.error(` - ${k}`);
+ }
+
if (extra.length > 0) {
// Extra keys are a warning, not a hard failure: they do not break i18n parity
// against the reference, but they signal drift worth cleaning up.
diff --git a/dashboard/src/i18n/locales/ar.json b/dashboard/src/i18n/locales/ar.json
index d6a6a471b..ec20be4bf 100644
--- a/dashboard/src/i18n/locales/ar.json
+++ b/dashboard/src/i18n/locales/ar.json
@@ -91,6 +91,7 @@
"unreadBadge_two": "{{count}} رسالتان غير مقروءتان",
"unreadBadge_few": "{{count}} رسائل غير مقروءة",
"unreadBadge_many": "{{count}} رسالة غير مقروءة",
+ "unreadBadge_zero": "{{count}} رسالة غير مقروءة",
"loadingMessages": "جارٍ تحميل الرسائل...",
"loadingOlderMessages": "جارٍ تحميل الرسائل الأقدم...",
"loadOlderMessagesError": "تعذر تحميل الرسائل الأقدم. مرر لأعلى للمحاولة مرة أخرى.",
@@ -166,7 +167,8 @@
"subscribers_other": "{{count}} مشترك",
"subscribers_two": "{{count}} مشتركان",
"subscribers_few": "{{count}} مشتركين",
- "subscribers_many": "{{count}} مشترك"
+ "subscribers_many": "{{count}} مشترك",
+ "subscribers_zero": "{{count}} مشترك"
},
"errors": {
"loadSessions": "فشل تحميل الجلسات",
diff --git a/dashboard/src/i18n/locales/es.json b/dashboard/src/i18n/locales/es.json
index eac265e42..e875f7726 100644
--- a/dashboard/src/i18n/locales/es.json
+++ b/dashboard/src/i18n/locales/es.json
@@ -88,6 +88,7 @@
"noMessageYet": "Aún sin mensajes",
"unreadBadge": "{{count}} mensaje sin leer",
"unreadBadge_other": "{{count}} mensajes sin leer",
+ "unreadBadge_many": "{{count}} mensajes sin leer",
"loadingMessages": "Cargando mensajes...",
"loadingOlderMessages": "Cargando mensajes anteriores...",
"loadOlderMessagesError": "No se pudieron cargar los mensajes anteriores. Desplázate hacia arriba para reintentar.",
@@ -131,6 +132,7 @@
"status": {
"itemCount": "{{count}} actualización",
"itemCount_other": "{{count}} actualizaciones",
+ "itemCount_many": "{{count}} actualizaciones",
"empty": "Ningún contacto tiene un estado activo.",
"loadError": "No se pudieron cargar los estados.",
"mediaUnavailable": "Contenido multimedia no disponible",
@@ -155,7 +157,8 @@
"empty": "Aún no estás suscrito a ningún canal.",
"notReady": "La sesión aún no está lista.",
"subscribers": "{{count}} suscriptor",
- "subscribers_other": "{{count}} suscriptores"
+ "subscribers_other": "{{count}} suscriptores",
+ "subscribers_many": "{{count}} suscriptores"
},
"errors": {
"loadSessions": "Error al cargar las sesiones",
@@ -428,6 +431,7 @@
"hint": "Activar solo cuando se cumplan todas las condiciones. Se aplica a eventos de mensajes.",
"badge": "{{count}} filtro",
"badge_other": "{{count}} filtros",
+ "badge_many": "{{count}} filtros",
"addCondition": "Añadir condición",
"removeCondition": "Eliminar condición",
"caseSensitive": "Distinguir mayúsculas",
diff --git a/dashboard/src/i18n/locales/fr.json b/dashboard/src/i18n/locales/fr.json
index 60da19910..01700e488 100644
--- a/dashboard/src/i18n/locales/fr.json
+++ b/dashboard/src/i18n/locales/fr.json
@@ -88,6 +88,7 @@
"noMessageYet": "Aucun message pour le moment",
"unreadBadge": "{{count}} message non lu",
"unreadBadge_other": "{{count}} messages non lus",
+ "unreadBadge_many": "{{count}} messages non lus",
"loadingMessages": "Chargement des messages...",
"loadingOlderMessages": "Chargement des messages plus anciens...",
"loadOlderMessagesError": "Impossible de charger les messages plus anciens. Faites défiler vers le haut pour réessayer.",
@@ -131,6 +132,7 @@
"status": {
"itemCount": "{{count}} mise à jour",
"itemCount_other": "{{count}} mises à jour",
+ "itemCount_many": "{{count}} mises à jour",
"empty": "Aucun contact n'a de statut actif.",
"loadError": "Échec du chargement des statuts.",
"mediaUnavailable": "Média indisponible",
@@ -155,7 +157,8 @@
"empty": "Vous n'êtes abonné à aucune chaîne pour le moment.",
"notReady": "La session n'est pas encore prête.",
"subscribers": "{{count}} abonné",
- "subscribers_other": "{{count}} abonnés"
+ "subscribers_other": "{{count}} abonnés",
+ "subscribers_many": "{{count}} abonnés"
},
"errors": {
"loadSessions": "Échec du chargement des sessions",
@@ -428,6 +431,7 @@
"hint": "Déclencher uniquement lorsque toutes les conditions sont remplies. S'applique aux événements de message.",
"badge": "{{count}} filtre",
"badge_other": "{{count}} filtres",
+ "badge_many": "{{count}} filtres",
"addCondition": "Ajouter une condition",
"removeCondition": "Supprimer la condition",
"caseSensitive": "Sensible à la casse",
diff --git a/dashboard/src/i18n/locales/it.json b/dashboard/src/i18n/locales/it.json
index 1643adab9..7e29a88c5 100644
--- a/dashboard/src/i18n/locales/it.json
+++ b/dashboard/src/i18n/locales/it.json
@@ -88,6 +88,7 @@
"noMessageYet": "Ancora nessun messaggio",
"unreadBadge": "{{count}} messaggio non letto",
"unreadBadge_other": "{{count}} messaggi non letti",
+ "unreadBadge_many": "{{count}} messaggi non letti",
"loadingMessages": "Caricamento messaggi...",
"loadingOlderMessages": "Caricamento messaggi precedenti...",
"loadOlderMessagesError": "Impossibile caricare i messaggi precedenti. Scorri verso l’alto per riprovare.",
@@ -131,6 +132,7 @@
"status": {
"itemCount": "{{count}} aggiornamento",
"itemCount_other": "{{count}} aggiornamenti",
+ "itemCount_many": "{{count}} aggiornamenti",
"empty": "Nessun contatto ha uno stato attivo.",
"loadError": "Impossibile caricare gli stati.",
"mediaUnavailable": "Contenuto multimediale non disponibile",
@@ -155,7 +157,8 @@
"empty": "Non sei ancora iscritto a nessun canale.",
"notReady": "La sessione non è ancora pronta.",
"subscribers": "{{count}} iscritto",
- "subscribers_other": "{{count}} iscritti"
+ "subscribers_other": "{{count}} iscritti",
+ "subscribers_many": "{{count}} iscritti"
},
"errors": {
"loadSessions": "Impossibile caricare le sessioni",
@@ -428,6 +431,7 @@
"hint": "Attiva solo quando tutte le condizioni corrispondono. Si applica agli eventi dei messaggi.",
"badge": "{{count}} filtro",
"badge_other": "{{count}} filtri",
+ "badge_many": "{{count}} filtri",
"addCondition": "Aggiungi condizione",
"removeCondition": "Rimuovi condizione",
"caseSensitive": "Distingui maiuscole",
diff --git a/dashboard/src/i18n/locales/pt-BR.json b/dashboard/src/i18n/locales/pt-BR.json
index 18de7eb82..f75424292 100644
--- a/dashboard/src/i18n/locales/pt-BR.json
+++ b/dashboard/src/i18n/locales/pt-BR.json
@@ -88,6 +88,7 @@
"noMessageYet": "Ainda sem mensagens",
"unreadBadge": "{{count}} mensagem não lida",
"unreadBadge_other": "{{count}} mensagens não lidas",
+ "unreadBadge_many": "{{count}} mensagens não lidas",
"loadingMessages": "Carregando mensagens...",
"loadingOlderMessages": "Carregando mensagens anteriores...",
"loadOlderMessagesError": "Não foi possível carregar mensagens anteriores. Role para cima para tentar novamente.",
@@ -131,6 +132,7 @@
"status": {
"itemCount": "{{count}} atualização",
"itemCount_other": "{{count}} atualizações",
+ "itemCount_many": "{{count}} atualizações",
"empty": "Nenhum contato tem um status ativo.",
"loadError": "Falha ao carregar os status.",
"mediaUnavailable": "Mídia indisponível",
@@ -155,7 +157,8 @@
"empty": "Você ainda não está inscrito em nenhum canal.",
"notReady": "A sessão ainda não está pronta.",
"subscribers": "{{count}} inscrito",
- "subscribers_other": "{{count}} inscritos"
+ "subscribers_other": "{{count}} inscritos",
+ "subscribers_many": "{{count}} inscritos"
},
"errors": {
"loadSessions": "Erro ao carregar as sessões",
@@ -428,6 +431,7 @@
"hint": "Disparar somente quando todas as condições forem atendidas. Aplica-se a eventos de mensagens.",
"badge": "{{count}} filtro",
"badge_other": "{{count}} filtros",
+ "badge_many": "{{count}} filtros",
"addCondition": "Adicionar condição",
"removeCondition": "Remover condição",
"caseSensitive": "Diferenciar maiúsculas",