Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(i18n): localize chat media labels, fix es placeholder + ar/he plurals, harden parity check (#547)

Yudhi Armyndharis1d578681a5ed
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d0e322ed5..9edf6bb4a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
+### Fixed
+
+- **Dashboard chat media labels are localized.** The omitted-media placeholder and the chat image `alt` text were hardcoded English; both now use the `chats.media.*` translation keys, added across all 10 locales. (#547)
+- **Spanish template-test hint interpolates correctly again.** The `templates.noPlaceholders` string had its `{{name}}` interpolation token localized to `{{nombre}}`, which broke substitution; the token is restored while the surrounding prose stays Spanish. (#547)
+- **Arabic and Hebrew filter-count badges use the correct plural form.** The `webhooks.filters.badge` count was missing the required CLDR plural categories for Arabic (zero/two/few/many) and Hebrew (two), so i18next fell back to the singular noun; the missing forms are now provided. (#547)
+
+### Changed
+
+- **The i18n parity check now catches more than missing keys.** It additionally hard-fails on a translated string whose `{{placeholder}}` tokens differ from the reference (the bug class above), and warns when a long value is byte-identical to English (likely untranslated) — giving a CI signal for locale drift. (#547)
### Security
- **Contact-card names escape vCard structural characters.** A contact whose name contained a backslash, semicolon, or comma could alter the structure of the generated vCard's `FN` field; those characters are now escaped per the vCard spec, complementing the existing CR/LF stripping. (#545)
diff --git a/dashboard/scripts/check-i18n-parity.mjs b/dashboard/scripts/check-i18n-parity.mjs
index e9a459327..fbea80caf 100644
--- a/dashboard/scripts/check-i18n-parity.mjs
+++ b/dashboard/scripts/check-i18n-parity.mjs
@@ -2,10 +2,13 @@
/**
* i18n locale parity check.
*
- * Loads the reference locale (en.json) and every other locale in
- * src/i18n/locales, then asserts that every nested key path present in
- * en.json also exists in each locale. Prints the missing key paths per
- * locale and exits non-zero if any are missing.
+ * Loads the reference locale (en.json) and every other locale in src/i18n/locales, then asserts:
+ * 1. KEY PARITY (hard fail): every nested key path in en.json exists in each locale.
+ * 2. PLACEHOLDER PARITY (hard fail): a translated string carries the SAME `{{token}}` interpolation
+ * placeholders as the reference — a localized/renamed token (e.g. `{{nombre}}` instead of
+ * `{{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).
*
* Wire into CI with: `npm run i18n:check`
*/
@@ -16,6 +19,9 @@ import { dirname, join } from 'node:path';
const __dirname = dirname(fileURLToPath(import.meta.url));
const LOCALES_DIR = join(__dirname, '..', 'src', 'i18n', 'locales');
const REFERENCE = 'en.json';
+// A leaf value identical to the reference is only flagged when at least this long — short UI words
+// (e.g. "Media", "OK") legitimately coincide across languages, full sentences almost never do.
+const UNTRANSLATED_MIN_LEN = 20;
/** Flatten a nested object into a Set of dot-separated key paths (leaf keys only). */
function flatten(obj, prefix = '', out = new Set()) {
@@ -30,11 +36,36 @@ function flatten(obj, prefix = '', out = new Set()) {
return out;
}
+/** Flatten to a Map of leaf path -> leaf value (string leaves matter for the value checks). */
+function flattenEntries(obj, prefix = '', out = new Map()) {
+ for (const [key, value] of Object.entries(obj)) {
+ const path = prefix ? `${prefix}.${key}` : key;
+ if (value && typeof value === 'object' && !Array.isArray(value)) {
+ flattenEntries(value, path, out);
+ } else {
+ out.set(path, value);
+ }
+ }
+ return out;
+}
+
+/** The set of `{{token}}` interpolation placeholders in a string. */
+function placeholders(str) {
+ const set = new Set();
+ for (const m of str.matchAll(/\{\{\s*([^}]+?)\s*\}\}/g)) set.add(m[1]);
+ return set;
+}
+
+function setsEqual(a, b) {
+ return a.size === b.size && [...a].every((x) => b.has(x));
+}
+
function load(file) {
return JSON.parse(readFileSync(join(LOCALES_DIR, file), 'utf8'));
}
-const reference = flatten(load(REFERENCE));
+const referenceKeys = flatten(load(REFERENCE));
+const referenceEntries = flattenEntries(load(REFERENCE));
const localeFiles = readdirSync(LOCALES_DIR)
.filter((f) => f.endsWith('.json') && f !== REFERENCE)
.sort();
@@ -43,15 +74,34 @@ let hasErrors = false;
for (const file of localeFiles) {
const keys = flatten(load(file));
- const missing = [...reference].filter((k) => !keys.has(k)).sort();
- const extra = [...keys].filter((k) => !reference.has(k)).sort();
+ const entries = flattenEntries(load(file));
+ const missing = [...referenceKeys].filter((k) => !keys.has(k)).sort();
+ const extra = [...keys].filter((k) => !referenceKeys.has(k)).sort();
+
+ const placeholderMismatches = [];
+ const untranslated = [];
+ for (const [path, refVal] of referenceEntries) {
+ if (typeof refVal !== 'string') continue;
+ const val = entries.get(path);
+ if (typeof val !== 'string') continue;
+ if (!setsEqual(placeholders(refVal), placeholders(val))) placeholderMismatches.push(path);
+ if (refVal === val && refVal.length >= UNTRANSLATED_MIN_LEN) untranslated.push(path);
+ }
if (missing.length > 0) {
hasErrors = true;
console.error(`\n[FAIL] ${file}: missing ${missing.length} key(s) present in ${REFERENCE}:`);
for (const k of missing) console.error(` - ${k}`);
} else {
- console.log(`[OK] ${file}: all ${reference.size} keys present`);
+ console.log(`[OK] ${file}: all ${referenceKeys.size} keys present`);
+ }
+
+ if (placeholderMismatches.length > 0) {
+ hasErrors = true;
+ console.error(`[FAIL] ${file}: ${placeholderMismatches.length} key(s) with mismatched {{placeholders}}:`);
+ for (const k of placeholderMismatches) {
+ console.error(` ! ${k}: expected ${[...placeholders(referenceEntries.get(k))].join(', ') || '(none)'}`);
+ }
}
if (extra.length > 0) {
@@ -60,6 +110,11 @@ for (const file of localeFiles) {
console.warn(`[WARN] ${file}: ${extra.length} extra key(s) not in ${REFERENCE}:`);
for (const k of extra) console.warn(` ~ ${k}`);
}
+
+ if (untranslated.length > 0) {
+ console.warn(`[WARN] ${file}: ${untranslated.length} long value(s) identical to ${REFERENCE} (likely untranslated):`);
+ for (const k of untranslated) console.warn(` ? ${k}`);
+ }
}
if (hasErrors) {
diff --git a/dashboard/src/i18n/locales/ar.json b/dashboard/src/i18n/locales/ar.json
index b41fd8b33..f5d0bb01a 100644
--- a/dashboard/src/i18n/locales/ar.json
+++ b/dashboard/src/i18n/locales/ar.json
@@ -83,7 +83,9 @@
"call": "مكالمة",
"callMissed": "مكالمة فائتة",
"callVideo": "مكالمة فيديو",
- "callVideoMissed": "مكالمة فيديو فائتة"
+ "callVideoMissed": "مكالمة فيديو فائتة",
+ "omitted": "وسائط",
+ "image": "صورة"
},
"subtitle": "أرسل ورد على رسائل واتساب في الوقت الفعلي",
"noSessionsTitle": "لا توجد جلسات متصلة",
@@ -303,10 +305,14 @@
"available": "الأحداث المتاحة",
"saveChanges": "حفظ التغييرات",
"filters": {
- "title": "عوامل التصفية (اختياري)",
- "hint": "يتم التفعيل فقط عند تطابق جميع الشروط. ينطبق على أحداث الرسائل.",
"badge": "{{count}} عامل تصفية",
+ "badge_zero": "بدون عوامل تصفية",
+ "badge_two": "عاملا تصفية",
+ "badge_few": "{{count}} عوامل تصفية",
+ "badge_many": "{{count}} عامل تصفية",
"badge_other": "{{count}} عوامل تصفية",
+ "title": "عوامل التصفية (اختياري)",
+ "hint": "يتم التفعيل فقط عند تطابق جميع الشروط. ينطبق على أحداث الرسائل.",
"addCondition": "إضافة شرط",
"removeCondition": "إزالة الشرط",
"caseSensitive": "حساس لحالة الأحرف",
diff --git a/dashboard/src/i18n/locales/en.json b/dashboard/src/i18n/locales/en.json
index 8a0dc6131..cf583512b 100644
--- a/dashboard/src/i18n/locales/en.json
+++ b/dashboard/src/i18n/locales/en.json
@@ -83,7 +83,9 @@
"call": "Call",
"callMissed": "Missed call",
"callVideo": "Video call",
- "callVideoMissed": "Missed video call"
+ "callVideoMissed": "Missed video call",
+ "omitted": "Media",
+ "image": "Image"
},
"subtitle": "Send and reply to WhatsApp messages in real time",
"noSessionsTitle": "No connected sessions",
diff --git a/dashboard/src/i18n/locales/es.json b/dashboard/src/i18n/locales/es.json
index 362fc8c2b..abf08f6c5 100644
--- a/dashboard/src/i18n/locales/es.json
+++ b/dashboard/src/i18n/locales/es.json
@@ -83,7 +83,9 @@
"call": "Llamada",
"callMissed": "Llamada perdida",
"callVideo": "Videollamada",
- "callVideoMissed": "Videollamada perdida"
+ "callVideoMissed": "Videollamada perdida",
+ "omitted": "Multimedia",
+ "image": "Imagen"
},
"subtitle": "Envía y responde mensajes de WhatsApp en tiempo real",
"noSessionsTitle": "Sin sesiones conectadas",
@@ -508,7 +510,7 @@
"previewTitle": "Vista previa",
"previewValuePlaceholder": "Valor de ejemplo",
"previewEmpty": "Empieza a escribir una plantilla para previsualizarla aquí.",
- "noPlaceholders": "Usa marcadores {{nombre}} para probar sustituciones.",
+ "noPlaceholders": "Usa marcadores {{name}} para probar sustituciones.",
"savedTitle": "Plantillas guardadas",
"count": "{{count}} en total",
"deleteTitle": "Eliminar plantilla",
diff --git a/dashboard/src/i18n/locales/fr.json b/dashboard/src/i18n/locales/fr.json
index f3d4d4275..9ceef2aa1 100644
--- a/dashboard/src/i18n/locales/fr.json
+++ b/dashboard/src/i18n/locales/fr.json
@@ -83,7 +83,9 @@
"call": "Appel",
"callMissed": "Appel manqué",
"callVideo": "Appel vidéo",
- "callVideoMissed": "Appel vidéo manqué"
+ "callVideoMissed": "Appel vidéo manqué",
+ "omitted": "Média",
+ "image": "Image"
},
"subtitle": "Envoyez et répondez aux messages WhatsApp en temps réel",
"noSessionsTitle": "Aucune session connectée",
diff --git a/dashboard/src/i18n/locales/he.json b/dashboard/src/i18n/locales/he.json
index 0bfe63bd0..ed974720b 100644
--- a/dashboard/src/i18n/locales/he.json
+++ b/dashboard/src/i18n/locales/he.json
@@ -83,7 +83,9 @@
"call": "שיחה",
"callMissed": "שיחה שלא נענתה",
"callVideo": "שיחת וידאו",
- "callVideoMissed": "שיחת וידאו שלא נענתה"
+ "callVideoMissed": "שיחת וידאו שלא נענתה",
+ "omitted": "מדיה",
+ "image": "תמונה"
},
"subtitle": "שליחה ומענה להודעות WhatsApp בזמן אמת",
"noSessionsTitle": "אין סשנים מחוברים",
@@ -303,10 +305,11 @@
"available": "אירועים זמינים",
"saveChanges": "שמירת שינויים",
"filters": {
- "title": "מסננים (אופציונלי)",
- "hint": "הפעלה רק כאשר כל התנאים מתקיימים. חל על אירועי הודעות.",
"badge": "{{count}} מסנן",
+ "badge_two": "שני מסננים",
"badge_other": "{{count}} מסננים",
+ "title": "מסננים (אופציונלי)",
+ "hint": "הפעלה רק כאשר כל התנאים מתקיימים. חל על אירועי הודעות.",
"addCondition": "הוספת תנאי",
"removeCondition": "הסרת תנאי",
"caseSensitive": "תלוי רישיות",
diff --git a/dashboard/src/i18n/locales/it.json b/dashboard/src/i18n/locales/it.json
index 4d7de516a..70c954a55 100644
--- a/dashboard/src/i18n/locales/it.json
+++ b/dashboard/src/i18n/locales/it.json
@@ -83,7 +83,9 @@
"call": "Chiamata",
"callMissed": "Chiamata persa",
"callVideo": "Videochiamata",
- "callVideoMissed": "Videochiamata persa"
+ "callVideoMissed": "Videochiamata persa",
+ "omitted": "Media",
+ "image": "Immagine"
},
"subtitle": "Invia e rispondi ai messaggi WhatsApp in tempo reale",
"noSessionsTitle": "Nessuna sessione connessa",
diff --git a/dashboard/src/i18n/locales/pt-BR.json b/dashboard/src/i18n/locales/pt-BR.json
index d6fcd5193..4f54c03e8 100644
--- a/dashboard/src/i18n/locales/pt-BR.json
+++ b/dashboard/src/i18n/locales/pt-BR.json
@@ -83,7 +83,9 @@
"call": "Chamada",
"callMissed": "Chamada perdida",
"callVideo": "Chamada de vídeo",
- "callVideoMissed": "Chamada de vídeo perdida"
+ "callVideoMissed": "Chamada de vídeo perdida",
+ "omitted": "Mídia",
+ "image": "Imagem"
},
"subtitle": "Envie e responda mensagens do WhatsApp em tempo real",
"noSessionsTitle": "Nenhuma sessão conectada",
diff --git a/dashboard/src/i18n/locales/te.json b/dashboard/src/i18n/locales/te.json
index 3be8198f4..fa0256eb5 100644
--- a/dashboard/src/i18n/locales/te.json
+++ b/dashboard/src/i18n/locales/te.json
@@ -83,7 +83,9 @@
"call": "కాల్",
"callMissed": "మిస్డ్ కాల్",
"callVideo": "వీడియో కాల్",
- "callVideoMissed": "మిస్డ్ వీడియో కాల్"
+ "callVideoMissed": "మిస్డ్ వీడియో కాల్",
+ "omitted": "మీడియా",
+ "image": "చిత్రం"
},
"subtitle": "వాట్సాప్ సందేశాలను నిజ-సమయంలో పంపండి మరియు ప్రత్యుత్తరం ఇవ్వండి",
"noSessionsTitle": "కనెక్ట్ అయిన సెషన్లు లేవు",
diff --git a/dashboard/src/i18n/locales/zh-CN.json b/dashboard/src/i18n/locales/zh-CN.json
index 6d0d8474d..e9681fb90 100644
--- a/dashboard/src/i18n/locales/zh-CN.json
+++ b/dashboard/src/i18n/locales/zh-CN.json
@@ -83,7 +83,9 @@
"call": "通话",
"callMissed": "未接来电",
"callVideo": "视频通话",
- "callVideoMissed": "未接视频通话"
+ "callVideoMissed": "未接视频通话",
+ "omitted": "媒体",
+ "image": "图片"
},
"subtitle": "实时发送和回复 WhatsApp 消息",
"noSessionsTitle": "没有已连接的会话",
diff --git a/dashboard/src/i18n/locales/zh-HK.json b/dashboard/src/i18n/locales/zh-HK.json
index dc7dce41b..0850cd1de 100644
--- a/dashboard/src/i18n/locales/zh-HK.json
+++ b/dashboard/src/i18n/locales/zh-HK.json
@@ -83,7 +83,9 @@
"call": "通話",
"callMissed": "未接來電",
"callVideo": "視像通話",
- "callVideoMissed": "未接視像通話"
+ "callVideoMissed": "未接視像通話",
+ "omitted": "媒體",
+ "image": "圖片"
},
"subtitle": "即時傳送和回覆 WhatsApp 訊息",
"noSessionsTitle": "沒有已連線的工作階段",
diff --git a/dashboard/src/pages/Chats.tsx b/dashboard/src/pages/Chats.tsx
index 11e0edc3d..0fac45e96 100644
--- a/dashboard/src/pages/Chats.tsx
+++ b/dashboard/src/pages/Chats.tsx
@@ -836,7 +836,7 @@ export function Chats() {
}
if (!mediaInfo) return null;
if (mediaInfo.omitted) {
- return <div className="message-media-omitted">📎 Media</div>;
+ return <div className="message-media-omitted">📎 {t('chats.media.omitted')}</div>;
}
const mediaSrc = getMediaSrc(mediaInfo);
if (!mediaSrc) return null;
@@ -848,7 +848,7 @@ export function Chats() {
<div className="message-media-image">
<img
src={mediaSrc}
- alt={mediaInfo.filename || 'WhatsApp Image'}
+ alt={mediaInfo.filename || t('chats.media.image')}
className="chat-image-media"
onClick={() => {
const idx = imageMedia.findIndex(x => x.id === msg.id);