From 229992853b43a30889e6890b5c2c9ff6a1228cf9 Mon Sep 17 00:00:00 2001 From: dealerweb Date: Fri, 29 May 2026 12:35:59 +0200 Subject: [PATCH] Fix: localize the PWA install prompt The PWA install prompt was hardcoded English regardless of the selected UI language (and the large English block tripped Chrome's translate popup on Android). Add a pwa_install namespace to all 17 locales, switch the component to useTranslations, and move from (main)/layout into (main)/[locale]/layout so it renders inside the IntlProvider. The title keeps the dynamic {appName}, so per-domain branding still applies. --- app/(main)/[locale]/layout.tsx | 2 ++ app/(main)/layout.tsx | 2 -- components/pwa-install-prompt.tsx | 14 ++++++++------ locales/cs/common.json | 8 ++++++++ locales/da/common.json | 8 ++++++++ locales/de/common.json | 8 ++++++++ locales/en/common.json | 8 ++++++++ locales/es/common.json | 8 ++++++++ locales/fr/common.json | 8 ++++++++ locales/it/common.json | 8 ++++++++ locales/ja/common.json | 8 ++++++++ locales/ko/common.json | 8 ++++++++ locales/lv/common.json | 8 ++++++++ locales/nl/common.json | 8 ++++++++ locales/pl/common.json | 8 ++++++++ locales/pt/common.json | 8 ++++++++ locales/ru/common.json | 8 ++++++++ locales/tr/common.json | 8 ++++++++ locales/uk/common.json | 8 ++++++++ locales/zh/common.json | 8 ++++++++ 20 files changed, 146 insertions(+), 8 deletions(-) diff --git a/app/(main)/[locale]/layout.tsx b/app/(main)/[locale]/layout.tsx index 60944ea5..8c3126af 100644 --- a/app/(main)/[locale]/layout.tsx +++ b/app/(main)/[locale]/layout.tsx @@ -9,6 +9,7 @@ import { ProtocolLaunchHandlerProvider } from "@/components/protocol/protocol-la import { ProInterfaceRedirect } from "@/components/pro/pro-interface-redirect"; import { PluginDialogHost } from "@/components/plugins/plugin-dialog-host"; import { PluginConsentDialog } from "@/components/plugins/plugin-consent-dialog"; +import { PWAInstallPrompt } from "@/components/pwa-install-prompt"; import { locales } from "@/i18n/routing"; export default async function LocaleLayout({ @@ -41,6 +42,7 @@ export default async function LocaleLayout({ {children} + diff --git a/app/(main)/layout.tsx b/app/(main)/layout.tsx index ac5c3b42..99468f94 100644 --- a/app/(main)/layout.tsx +++ b/app/(main)/layout.tsx @@ -2,7 +2,6 @@ import type { Metadata, Viewport } from "next"; import { Geist, Geist_Mono } from "next/font/google"; import { headers } from "next/headers"; import { getLocale } from "next-intl/server"; -import { PWAInstallPrompt } from "@/components/pwa-install-prompt"; import { ServiceWorkerRegistration } from "@/components/service-worker-registration"; import { configManager } from "@/lib/admin/config-manager"; import { withBasePath } from "@/lib/browser-navigation"; @@ -92,7 +91,6 @@ export default async function RootLayout({ > {children} - ); diff --git a/components/pwa-install-prompt.tsx b/components/pwa-install-prompt.tsx index 00c8bfb3..4cc95f95 100644 --- a/components/pwa-install-prompt.tsx +++ b/components/pwa-install-prompt.tsx @@ -1,6 +1,7 @@ "use client"; import { useEffect, useState } from "react"; +import { useTranslations } from "next-intl"; import { X, Download } from "lucide-react"; import { useConfig } from "@/hooks/use-config"; import { withBasePath } from "@/lib/browser-navigation"; @@ -17,6 +18,7 @@ export function PWAInstallPrompt() { useState(null); const [showPrompt, setShowPrompt] = useState(false); const { appName, faviconUrl, appLogoLightUrl, appLogoDarkUrl } = useConfig(); + const t = useTranslations("pwa_install"); useEffect(() => { if (localStorage.getItem(DISMISSED_KEY)) return; @@ -84,17 +86,17 @@ export function PWAInstallPrompt() { )}

- Install {appName} + {t("title", { appName })}

- Install our app for quick access and offline support. + {t("description")}

@@ -105,20 +107,20 @@ export function PWAInstallPrompt() { onClick={handleDismiss} className="flex-1 px-3 py-2 text-sm font-medium text-neutral-700 dark:text-neutral-300 bg-neutral-100 dark:bg-neutral-800 rounded hover:bg-neutral-200 dark:hover:bg-neutral-700 transition-colors" > - Not now + {t("not_now")} diff --git a/locales/cs/common.json b/locales/cs/common.json index 6620a55b..40b0ed6a 100644 --- a/locales/cs/common.json +++ b/locales/cs/common.json @@ -1,4 +1,12 @@ { + "pwa_install": { + "title": "Nainstalovat {appName}", + "description": "Nainstalujte si naši aplikaci pro rychlý přístup a offline podporu.", + "not_now": "Teď ne", + "install": "Nainstalovat", + "dont_remind": "Už mi to nepřipomínat", + "dismiss_aria": "Zavřít výzvu k instalaci" + }, "login": { "title": "Webmail", "username_label": "E-mail", diff --git a/locales/da/common.json b/locales/da/common.json index 2f455b42..7b379c5d 100644 --- a/locales/da/common.json +++ b/locales/da/common.json @@ -1,4 +1,12 @@ { + "pwa_install": { + "title": "Installer {appName}", + "description": "Installer vores app for hurtig adgang og offline-understøttelse.", + "not_now": "Ikke nu", + "install": "Installer", + "dont_remind": "Påmind mig ikke igen", + "dismiss_aria": "Afvis installationsprompt" + }, "login": { "title": "Webmail", "username_label": "Email", diff --git a/locales/de/common.json b/locales/de/common.json index fa621a99..7b3cd5ca 100644 --- a/locales/de/common.json +++ b/locales/de/common.json @@ -1,4 +1,12 @@ { + "pwa_install": { + "title": "{appName} installieren", + "description": "Installiere unsere App für schnellen Zugriff und Offline-Unterstützung.", + "not_now": "Nicht jetzt", + "install": "Installieren", + "dont_remind": "Nicht mehr erinnern", + "dismiss_aria": "Installationshinweis schließen" + }, "login": { "title": "Webmail", "username_label": "E-Mail", diff --git a/locales/en/common.json b/locales/en/common.json index 1dbba593..f9ababbe 100644 --- a/locales/en/common.json +++ b/locales/en/common.json @@ -1,4 +1,12 @@ { + "pwa_install": { + "title": "Install {appName}", + "description": "Install our app for quick access and offline support.", + "not_now": "Not now", + "install": "Install", + "dont_remind": "Don't remind me again", + "dismiss_aria": "Dismiss install prompt" + }, "login": { "title": "Webmail", "username_label": "Email", diff --git a/locales/es/common.json b/locales/es/common.json index 7b83d66a..c75a5ed2 100644 --- a/locales/es/common.json +++ b/locales/es/common.json @@ -1,4 +1,12 @@ { + "pwa_install": { + "title": "Instalar {appName}", + "description": "Instala nuestra app para un acceso rápido y soporte sin conexión.", + "not_now": "Ahora no", + "install": "Instalar", + "dont_remind": "No volver a recordármelo", + "dismiss_aria": "Cerrar aviso de instalación" + }, "login": { "title": "Correo Web", "username_label": "Correo electrónico", diff --git a/locales/fr/common.json b/locales/fr/common.json index f9cb00ad..3d8b23ce 100644 --- a/locales/fr/common.json +++ b/locales/fr/common.json @@ -1,4 +1,12 @@ { + "pwa_install": { + "title": "Installer {appName}", + "description": "Installez notre application pour un accès rapide et un support hors ligne.", + "not_now": "Pas maintenant", + "install": "Installer", + "dont_remind": "Ne plus me le rappeler", + "dismiss_aria": "Fermer l'invite d'installation" + }, "login": { "title": "Webmail", "username_label": "Email", diff --git a/locales/it/common.json b/locales/it/common.json index 3c96458a..59e685d9 100644 --- a/locales/it/common.json +++ b/locales/it/common.json @@ -1,4 +1,12 @@ { + "pwa_install": { + "title": "Installa {appName}", + "description": "Installa la nostra app per un accesso rapido e il supporto offline.", + "not_now": "Non ora", + "install": "Installa", + "dont_remind": "Non ricordarmelo più", + "dismiss_aria": "Chiudi avviso di installazione" + }, "login": { "title": "Webmail", "username_label": "Email", diff --git a/locales/ja/common.json b/locales/ja/common.json index aa366688..19790b80 100644 --- a/locales/ja/common.json +++ b/locales/ja/common.json @@ -1,4 +1,12 @@ { + "pwa_install": { + "title": "{appName} をインストール", + "description": "素早いアクセスとオフライン対応のため、アプリをインストールしましょう。", + "not_now": "後で", + "install": "インストール", + "dont_remind": "今後表示しない", + "dismiss_aria": "インストールプロンプトを閉じる" + }, "login": { "title": "ウェブメール", "username_label": "メールアドレス", diff --git a/locales/ko/common.json b/locales/ko/common.json index 79a238d7..fc5cc258 100644 --- a/locales/ko/common.json +++ b/locales/ko/common.json @@ -1,4 +1,12 @@ { + "pwa_install": { + "title": "{appName} 설치", + "description": "빠른 액세스와 오프라인 지원을 위해 앱을 설치하세요.", + "not_now": "나중에", + "install": "설치", + "dont_remind": "다시 알리지 않음", + "dismiss_aria": "설치 프롬프트 닫기" + }, "login": { "title": "웹메일", "username_label": "이메일", diff --git a/locales/lv/common.json b/locales/lv/common.json index 62a09509..980f1e3c 100644 --- a/locales/lv/common.json +++ b/locales/lv/common.json @@ -1,4 +1,12 @@ { + "pwa_install": { + "title": "Instalēt {appName}", + "description": "Instalējiet mūsu lietotni ātrai piekļuvei un bezsaistes atbalstam.", + "not_now": "Ne tagad", + "install": "Instalēt", + "dont_remind": "Vairs man neatgādināt", + "dismiss_aria": "Aizvērt instalēšanas paziņojumu" + }, "login": { "title": "Tīmekļa pasts", "username_label": "E-pasta adrese", diff --git a/locales/nl/common.json b/locales/nl/common.json index d1208b36..49b62770 100644 --- a/locales/nl/common.json +++ b/locales/nl/common.json @@ -1,4 +1,12 @@ { + "pwa_install": { + "title": "{appName} installeren", + "description": "Installeer onze app voor snelle toegang en offline-ondersteuning.", + "not_now": "Niet nu", + "install": "Installeren", + "dont_remind": "Niet meer herinneren", + "dismiss_aria": "Installatiemelding sluiten" + }, "login": { "title": "Webmail", "username_label": "E-mail", diff --git a/locales/pl/common.json b/locales/pl/common.json index ee550e28..b4d08a91 100644 --- a/locales/pl/common.json +++ b/locales/pl/common.json @@ -1,4 +1,12 @@ { + "pwa_install": { + "title": "Zainstaluj {appName}", + "description": "Zainstaluj naszą aplikację, aby uzyskać szybki dostęp i obsługę offline.", + "not_now": "Nie teraz", + "install": "Zainstaluj", + "dont_remind": "Nie przypominaj mi więcej", + "dismiss_aria": "Zamknij monit instalacji" + }, "login": { "title": "Webmail", "username_label": "E-mail", diff --git a/locales/pt/common.json b/locales/pt/common.json index 3f7ef129..6b8d8408 100644 --- a/locales/pt/common.json +++ b/locales/pt/common.json @@ -1,4 +1,12 @@ { + "pwa_install": { + "title": "Instalar {appName}", + "description": "Instale o nosso app para acesso rápido e suporte offline.", + "not_now": "Agora não", + "install": "Instalar", + "dont_remind": "Não lembrar novamente", + "dismiss_aria": "Dispensar aviso de instalação" + }, "login": { "title": "Webmail", "username_label": "E-mail", diff --git a/locales/ru/common.json b/locales/ru/common.json index 747b269c..0d4302af 100644 --- a/locales/ru/common.json +++ b/locales/ru/common.json @@ -1,4 +1,12 @@ { + "pwa_install": { + "title": "Установить {appName}", + "description": "Установите наше приложение для быстрого доступа и работы офлайн.", + "not_now": "Не сейчас", + "install": "Установить", + "dont_remind": "Больше не напоминать", + "dismiss_aria": "Закрыть запрос на установку" + }, "login": { "title": "Веб-почта", "username_label": "Электронная почта", diff --git a/locales/tr/common.json b/locales/tr/common.json index 287522ab..a0728370 100644 --- a/locales/tr/common.json +++ b/locales/tr/common.json @@ -1,4 +1,12 @@ { + "pwa_install": { + "title": "{appName} uygulamasını yükle", + "description": "Hızlı erişim ve çevrimdışı destek için uygulamamızı yükleyin.", + "not_now": "Şimdi değil", + "install": "Yükle", + "dont_remind": "Bir daha hatırlatma", + "dismiss_aria": "Yükleme istemini kapat" + }, "login": { "title": "Webmail", "username_label": "E-posta", diff --git a/locales/uk/common.json b/locales/uk/common.json index e08ee372..3e0601e3 100644 --- a/locales/uk/common.json +++ b/locales/uk/common.json @@ -1,4 +1,12 @@ { + "pwa_install": { + "title": "Встановити {appName}", + "description": "Встановіть наш застосунок для швидкого доступу та офлайн-підтримки.", + "not_now": "Не зараз", + "install": "Встановити", + "dont_remind": "Більше не нагадувати", + "dismiss_aria": "Закрити запит на встановлення" + }, "login": { "title": "Веб-пошта", "username_label": "Електронна пошта", diff --git a/locales/zh/common.json b/locales/zh/common.json index 00a7634f..cd296f35 100644 --- a/locales/zh/common.json +++ b/locales/zh/common.json @@ -1,4 +1,12 @@ { + "pwa_install": { + "title": "安装 {appName}", + "description": "安装我们的应用,以获得快速访问和离线支持。", + "not_now": "暂不", + "install": "安装", + "dont_remind": "不再提醒", + "dismiss_aria": "关闭安装提示" + }, "login": { "title": "网页邮箱", "username_label": "邮箱地址",