From 118f84830837b18849917afcd4b84ef0fc48cea5 Mon Sep 17 00:00:00 2001 From: Dan Ditomaso Date: Mon, 16 Jun 2025 16:22:45 -0400 Subject: [PATCH 1/3] feat: add support for 3 languages (#661) --- src/i18n/config.ts | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/i18n/config.ts b/src/i18n/config.ts index a028a25c..fddfde8f 100644 --- a/src/i18n/config.ts +++ b/src/i18n/config.ts @@ -11,6 +11,11 @@ export type Lang = { export type LangCode = Lang["code"]; +/** + * Generates a flag emoji from a two-letter country code. + * @param regionCode - The two-letter, uppercase country code (e.g., "US", "FI"). + * @returns A string containing the flag emoji. + */ function getFlagEmoji(regionCode: string): string { const A_LETTER_CODE = 0x1F1E6; const a_char_code = "A".charCodeAt(0); @@ -22,10 +27,10 @@ function getFlagEmoji(regionCode: string): string { } export const supportedLanguages: Lang[] = [ - { code: "de", name: "German", flag: getFlagEmoji("de") }, - { code: "en", name: "English", flag: getFlagEmoji("us") }, - { code: "fi", name: "Finnish", flag: getFlagEmoji("fi") }, - { code: "sv", name: "Swedish", flag: getFlagEmoji("se") }, + { code: "de-DE", name: "Deutschland", flag: getFlagEmoji("DE") }, + { code: "en-US", name: "English", flag: getFlagEmoji("US") }, + { code: "fi-FI", name: "Suomi", flag: getFlagEmoji("FI") }, + { code: "sv-SE", name: "Svenska", flag: getFlagEmoji("SE") }, ]; i18next @@ -34,19 +39,18 @@ i18next .use(LanguageDetector) .init({ backend: { - // this will lazy load resources from the i18n folder + // With this setup, {{lng}} will correctly resolve to 'en-US', 'fi-FI', etc. loadPath: "/src/i18n/locales/{{lng}}/{{ns}}.json", }, react: { useSuspense: true, }, + nonExplicitSupportedLngs: true, detection: { - order: ["navigator", "localStorage"], + order: ["localStorage", "navigator"], caches: ["localStorage"], }, - fallbackLng: { - "default": ["en"], - }, + fallbackLng: "en-US", // Default to US English if detection fails fallbackNS: ["common", "ui", "dialog"], debug: import.meta.env.MODE === "development", ns: [ From ccc4202aa406638976076c109a6e6449462d3b76 Mon Sep 17 00:00:00 2001 From: Jeremy Gallant <8975765+philon-@users.noreply.github.com> Date: Tue, 17 Jun 2025 16:24:58 +0200 Subject: [PATCH 2/3] Minor i18n fixes (#663) * i18n fixes Add PKI Backup Reminder dialog + ensure en-US is UI default * Revert edits to i18n components --- src/components/KeyBackupReminder.tsx | 2 +- src/core/hooks/useKeyBackupReminder.tsx | 14 ++++++++++---- src/i18n/locales/en/common.json | 1 + src/i18n/locales/en/dialog.json | 8 +++++++- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/components/KeyBackupReminder.tsx b/src/components/KeyBackupReminder.tsx index aefe60ec..32cacd1a 100644 --- a/src/components/KeyBackupReminder.tsx +++ b/src/components/KeyBackupReminder.tsx @@ -7,7 +7,7 @@ export const KeyBackupReminder = () => { const { t } = useTranslation("dialog"); useBackupReminder({ - message: t("pkiBackup.description"), + message: t("pkiBackupReminder.description"), onAccept: () => setDialogOpen("pkiBackup", true), enabled: true, }); diff --git a/src/core/hooks/useKeyBackupReminder.tsx b/src/core/hooks/useKeyBackupReminder.tsx index 9e71c2fa..eaadce14 100644 --- a/src/core/hooks/useKeyBackupReminder.tsx +++ b/src/core/hooks/useKeyBackupReminder.tsx @@ -2,6 +2,7 @@ import { Button } from "@components/UI/Button.tsx"; import { useCallback, useEffect, useRef } from "react"; import { useToast } from "@core/hooks/useToast.ts"; import useLocalStorage from "@core/hooks/useLocalStorage.ts"; +import { useTranslation } from "react-i18next"; interface UseBackupReminderOptions { reminderInDays?: number; @@ -36,6 +37,8 @@ export function useBackupReminder({ onAccept = () => {}, reminderInDays = REMINDER_DAYS_ONE_WEEK, }: UseBackupReminderOptions) { + const { t } = useTranslation("dialog"); + const { toast } = useToast(); const toastShownRef = useRef(false); const [reminderState, setReminderState] = useLocalStorage< @@ -59,7 +62,7 @@ export function useBackupReminder({ toastShownRef.current = true; const { dismiss } = toast({ - title: "Backup Reminder", + title: t("pkiBackupReminder.title"), duration: TOAST_DURATION, delay: TOAST_APPEAR_DELAY, description: message, @@ -75,7 +78,10 @@ export function useBackupReminder({ setReminderExpiry(reminderInDays); }} > - Remind me in {reminderInDays} day{reminderInDays > 1 ? "s" : ""} + {t("pkiBackupReminder.remindLaterPrefix")} {reminderInDays}{" "} + {reminderInDays > 1 + ? t("common:unit.day.plural").toLowerCase() + : t("common:unit.day.one").toLowerCase()} ), diff --git a/src/i18n/locales/en/common.json b/src/i18n/locales/en/common.json index efb44b14..5597f53a 100644 --- a/src/i18n/locales/en/common.json +++ b/src/i18n/locales/en/common.json @@ -54,6 +54,7 @@ "suffix": "ms" }, "second": { "one": "Second", "plural": "Seconds" }, + "day": { "one": "Day", "plural": "Days" }, "snr": "SNR", "volt": { "one": "Volt", "plural": "Volts", "suffix": "V" }, "record": { "one": "Records", "plural": "Records" } diff --git a/src/i18n/locales/en/dialog.json b/src/i18n/locales/en/dialog.json index 23393156..28427867 100644 --- a/src/i18n/locales/en/dialog.json +++ b/src/i18n/locales/en/dialog.json @@ -93,7 +93,6 @@ "unignoreNode": "Unignore node" }, "pkiBackup": { - "description": "We recommend backing up your key data regularly. Would you like to back up now?", "loseKeysWarning": "If you lose your keys, you will need to reset your device.", "secureBackup": "Its important to backup your public and private keys and store your backup securely!", "footer": "=== END OF KEYS ===", @@ -103,6 +102,13 @@ "fileName": "meshtastic_keys_{{longName}}_{{shortName}}.txt", "title": "Backup Keys" }, + "pkiBackupReminder": { + "description": "We recommend backing up your key data regularly. Would you like to back up now?", + "title": "Backup Reminder", + "remindLaterPrefix": "Remind me in", + "remindNever": "Never remind me", + "backupNow": "Back up now" + }, "pkiRegenerate": { "description": "Are you sure you want to regenerate key pair?", "title": "Regenerate Key Pair" From c91e5e6b7b99b70a4b3f8665d0af8de5b8764dbf Mon Sep 17 00:00:00 2001 From: Dan Ditomaso Date: Tue, 17 Jun 2025 11:09:43 -0400 Subject: [PATCH 3/3] fix: add rewrites to vercel.json (#662) --- vercel.json | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/vercel.json b/vercel.json index 24bca4be..52503763 100644 --- a/vercel.json +++ b/vercel.json @@ -1,5 +1,11 @@ { - "github": { "silent": true }, + "$schema": "https://openapi.vercel.sh/vercel.json", + "rewrites": [ + { + "source": "/((?!api|.*\\..*).*)", + "destination": "/index.html" + } + ], "headers": [ { "source": "/",