From 0c812d9390b688691a81d70dd08122f5a96a9447 Mon Sep 17 00:00:00 2001 From: BillionClaw <267901332+BillionClaw@users.noreply.github.com> Date: Tue, 17 Mar 2026 14:17:39 +0800 Subject: [PATCH] fix(i18n): use translation keys for upload notification titles Replace hardcoded English/Spanish strings with proper i18n translations for upload notification titles and file count labels. - Add upload.files translation key to all locale files - Update notifications.js to use window.i18n.t() for: - upload.uploading title - upload.files file count label - upload.complete completion message Fixes #108 --- static/js/core/notifications.js | 20 +++++++++----------- static/locales/ar.json | 1 + static/locales/de.json | 1 + static/locales/en.json | 1 + static/locales/es.json | 1 + static/locales/fa.json | 1 + static/locales/fr.json | 1 + static/locales/hi.json | 1 + static/locales/it.json | 1 + static/locales/ja.json | 1 + static/locales/ko.json | 1 + static/locales/nl.json | 1 + static/locales/pt.json | 1 + static/locales/ru.json | 1 + static/locales/zh.json | 1 + 15 files changed, 23 insertions(+), 11 deletions(-) diff --git a/static/js/core/notifications.js b/static/js/core/notifications.js index c9138c93..6c48920d 100755 --- a/static/js/core/notifications.js +++ b/static/js/core/notifications.js @@ -143,11 +143,11 @@ const notifications = (() => { item.className = 'notif-item'; item.id = batchId; - const locale = window.i18n?.getCurrentLocale?.() || 'en'; + const t = window.i18n?.t || ((k) => k); const uploadingText = folderName - ? (locale.startsWith('es') ? `📁 Subiendo ${_esc(folderName)}…` : `📁 Uploading ${_esc(folderName)}…`) - : (locale.startsWith('es') ? 'Subiendo…' : 'Uploading…'); - const filesLabel = locale.startsWith('es') ? 'archivos' : 'files'; + ? `📁 ${t('upload.uploading')} ${_esc(folderName)}…` + : t('upload.uploading'); + const filesLabel = t('upload.files'); item.innerHTML = `
@@ -254,8 +254,8 @@ const notifications = (() => { const pctEl = $(batchId + '-pct'); const statsEl = $(batchId + '-stats'); - const locale = window.i18n?.getCurrentLocale?.() || 'en'; - const filesLabel = locale.startsWith('es') ? 'archivos' : 'files'; + const t = window.i18n?.t || ((k) => k); + const filesLabel = t('upload.files'); if (fillEl) fillEl.style.width = pctVal + '%'; if (pctEl) pctEl.textContent = pctVal + '%'; @@ -282,11 +282,9 @@ const notifications = (() => { const curEl = $(batchId + '-current'); if (curEl) curEl.textContent = ''; - const locale = window.i18n?.getCurrentLocale?.() || 'en'; - const filesLabel = locale.startsWith('es') ? 'archivos' : 'files'; - const completeText = locale.startsWith('es') - ? `✅ ${successCount} / ${totalFiles} ${filesLabel} subidos` - : `✅ ${successCount} / ${totalFiles} ${filesLabel} uploaded`; + const t = window.i18n?.t || ((k) => k); + const filesLabel = t('upload.files'); + const completeText = t('upload.complete', { count: successCount, total: totalFiles }); if (titleEl) titleEl.textContent = completeText; if (iconEl) { diff --git a/static/locales/ar.json b/static/locales/ar.json index b9e7b477..f1c296e1 100644 --- a/static/locales/ar.json +++ b/static/locales/ar.json @@ -27,6 +27,7 @@ "upload_folder": "رفع مجلد", "upload.uploading": "جارٍ الرفع...", "upload.complete": "{count} / {total} تم رفعها", + "upload.files": "ملفات", "rename": "إعادة التسمية", "move": "نقل إلى...", "move_to": "نقل إلى", diff --git a/static/locales/de.json b/static/locales/de.json index 4566dadb..6bf7af57 100755 --- a/static/locales/de.json +++ b/static/locales/de.json @@ -27,6 +27,7 @@ "upload_folder": "Ordner hochladen", "upload.uploading": "Wird hochgeladen...", "upload.complete": "{count} / {total} hochgeladen", + "upload.files": "Dateien", "rename": "Umbenennen", "move": "Verschieben nach...", "move_to": "Verschieben nach", diff --git a/static/locales/en.json b/static/locales/en.json index c7585148..88608695 100755 --- a/static/locales/en.json +++ b/static/locales/en.json @@ -27,6 +27,7 @@ "upload_folder": "Upload folder", "upload.uploading": "Uploading...", "upload.complete": "{count} / {total} uploaded", + "upload.files": "files", "rename": "Rename", "move": "Move to...", "move_to": "Move to", diff --git a/static/locales/es.json b/static/locales/es.json index 58a15aa5..bc2017dc 100755 --- a/static/locales/es.json +++ b/static/locales/es.json @@ -146,6 +146,7 @@ "upload_folder": "Subir carpeta", "upload.uploading": "Subiendo...", "upload.complete": "{count} / {total} subidos", + "upload.files": "archivos", "rename": "Renombrar", "move": "Mover a...", "move_to": "Mover a", diff --git a/static/locales/fa.json b/static/locales/fa.json index 20b86aed..5f6578aa 100755 --- a/static/locales/fa.json +++ b/static/locales/fa.json @@ -27,6 +27,7 @@ "upload_folder": "بارگذاری پوشه", "upload.uploading": "...در حال بارگذاری", "upload.complete": "{count} / {total} بارگذاری شد", + "upload.files": "فایلها", "rename": "تغییر نام", "move": "انتقال به...", "move_to": "انتقال به", diff --git a/static/locales/fr.json b/static/locales/fr.json index 96d762ea..dda1b99d 100755 --- a/static/locales/fr.json +++ b/static/locales/fr.json @@ -27,6 +27,7 @@ "upload_folder": "Téléverser un dossier", "upload.uploading": "Envoi en cours...", "upload.complete": "{count} / {total} envoyés", + "upload.files": "fichiers", "rename": "Renommer", "move": "Déplacer vers...", "move_to": "Déplacer vers", diff --git a/static/locales/hi.json b/static/locales/hi.json index 2b87ff9a..dae6c403 100644 --- a/static/locales/hi.json +++ b/static/locales/hi.json @@ -27,6 +27,7 @@ "upload_folder": "फ़ोल्डर अपलोड करें", "upload.uploading": "अपलोड हो रहा है...", "upload.complete": "{count} / {total} अपलोड हुईं", + "upload.files": "फ़ाइलें", "rename": "नाम बदलें", "move": "यहाँ ले जाएँ...", "move_to": "यहाँ ले जाएँ", diff --git a/static/locales/it.json b/static/locales/it.json index fa5dec05..117ab24f 100755 --- a/static/locales/it.json +++ b/static/locales/it.json @@ -27,6 +27,7 @@ "upload_folder": "Carica cartella", "upload.uploading": "Caricamento...", "upload.complete": "{count} / {total} caricati", + "upload.files": "file", "rename": "Rinomina", "move": "Sposta in...", "move_to": "Sposta in", diff --git a/static/locales/ja.json b/static/locales/ja.json index 5158cb11..cb828fe4 100644 --- a/static/locales/ja.json +++ b/static/locales/ja.json @@ -27,6 +27,7 @@ "upload_folder": "フォルダをアップロード", "upload.uploading": "アップロード中...", "upload.complete": "{count} / {total} アップロード完了", + "upload.files": "ファイル", "rename": "名前を変更", "move": "移動先...", "move_to": "移動先", diff --git a/static/locales/ko.json b/static/locales/ko.json index 75c55e1b..6a2f5d07 100644 --- a/static/locales/ko.json +++ b/static/locales/ko.json @@ -27,6 +27,7 @@ "upload_folder": "폴더 업로드", "upload.uploading": "업로드 중...", "upload.complete": "{count} / {total} 업로드 완료", + "upload.files": "파일", "rename": "이름 변경", "move": "이동...", "move_to": "이동 대상", diff --git a/static/locales/nl.json b/static/locales/nl.json index cb8b55dd..683e65d2 100755 --- a/static/locales/nl.json +++ b/static/locales/nl.json @@ -27,6 +27,7 @@ "upload_folder": "Map uploaden", "upload.uploading": "Uploaden...", "upload.complete": "{count} / {total} geüpload", + "upload.files": "bestanden", "rename": "Hernoemen", "move": "Verplaatsen naar...", "move_to": "Verplaatsen naar", diff --git a/static/locales/pt.json b/static/locales/pt.json index 2689fe96..6f4b6f44 100755 --- a/static/locales/pt.json +++ b/static/locales/pt.json @@ -27,6 +27,7 @@ "upload_folder": "Enviar pasta", "upload.uploading": "Enviando...", "upload.complete": "{count} / {total} enviados", + "upload.files": "arquivos", "rename": "Renomear", "move": "Mover para...", "move_to": "Mover para", diff --git a/static/locales/ru.json b/static/locales/ru.json index 91a3b9f1..6ff06409 100644 --- a/static/locales/ru.json +++ b/static/locales/ru.json @@ -27,6 +27,7 @@ "upload_folder": "Загрузить папку", "upload.uploading": "Загрузка...", "upload.complete": "{count} / {total} загружено", + "upload.files": "файлов", "rename": "Переименовать", "move": "Переместить в...", "move_to": "Переместить в", diff --git a/static/locales/zh.json b/static/locales/zh.json index c29943de..0579b863 100755 --- a/static/locales/zh.json +++ b/static/locales/zh.json @@ -27,6 +27,7 @@ "upload_folder": "上传文件夹", "upload.uploading": "上传中...", "upload.complete": "{count} / {total} 已上传", + "upload.files": "文件", "rename": "重命名", "move": "移动到...", "move_to": "移动到",