update translations

This commit is contained in:
Henry Dollman
2024-11-04 15:42:23 -05:00
parent 2b6560b9e1
commit 9e959a6b7b
20 changed files with 123 additions and 141 deletions

View File

@@ -2,7 +2,7 @@ import { LanguagesIcon } from "lucide-react"
import { Button } from "@/components/ui/button" import { Button } from "@/components/ui/button"
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@/components/ui/dropdown-menu" import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@/components/ui/dropdown-menu"
import languages from "../lib/languages.json" import languages from "@/lib/languages"
import { cn } from "@/lib/utils" import { cn } from "@/lib/utils"
import { useLingui } from "@lingui/react" import { useLingui } from "@lingui/react"
import { dynamicActivate } from "@/lib/i18n" import { dynamicActivate } from "@/lib/i18n"

View File

@@ -8,7 +8,7 @@ import { UserSettings } from "@/types"
import { saveSettings } from "./layout" import { saveSettings } from "./layout"
import { useState } from "react" import { useState } from "react"
import { Trans } from "@lingui/macro" import { Trans } from "@lingui/macro"
import languages from "../../../lib/languages.json" import languages from "@/lib/languages"
import { dynamicActivate } from "@/lib/i18n" import { dynamicActivate } from "@/lib/i18n"
import { useLingui } from "@lingui/react" import { useLingui } from "@lingui/react"
// import { setLang } from "@/lib/i18n" // import { setLang } from "@/lib/i18n"

View File

@@ -1,12 +1,10 @@
import { $direction } from "./stores" import { $direction } from "./stores"
import { i18n } from "@lingui/core" import { i18n } from "@lingui/core"
import type { Messages } from "@lingui/core" import type { Messages } from "@lingui/core"
import languages from "@/lib/languages.json" import languages from "@/lib/languages"
import { detect, fromUrl, fromStorage, fromNavigator } from "@lingui/detect-locale" import { detect, fromUrl, fromStorage, fromNavigator } from "@lingui/detect-locale"
import { messages as enMessages } from "../locales/en/en.ts" import { messages as enMessages } from "../locales/en/en.ts"
console.log(languages)
// let locale = detect(fromUrl("lang"), fromStorage("lang"), fromNavigator(), "en") // let locale = detect(fromUrl("lang"), fromStorage("lang"), fromNavigator(), "en")
let locale = detect(fromStorage("lang"), fromNavigator(), "en") let locale = detect(fromStorage("lang"), fromNavigator(), "en")
@@ -25,13 +23,17 @@ function activateLocale(locale: string, messages: Messages = enMessages) {
// dynamically loads translations for the given locale // dynamically loads translations for the given locale
export async function dynamicActivate(locale: string) { export async function dynamicActivate(locale: string) {
try { if (locale == "en") {
const { messages }: { messages: Messages } = await import(`../locales/${locale}/${locale}.ts`) activateLocale(locale)
activateLocale(locale, messages) } else {
localStorage.setItem("lang", locale) try {
} catch (error) { const { messages }: { messages: Messages } = await import(`../locales/${locale}/${locale}.ts`)
console.error(`Error loading ${locale}`, error) activateLocale(locale, messages)
activateLocale("en") localStorage.setItem("lang", locale)
} catch (error) {
console.error(`Error loading ${locale}`, error)
activateLocale("en")
}
} }
} }
@@ -56,11 +58,5 @@ if (locale?.startsWith("zh-")) {
if (!languages.some((l) => l.lang === locale)) { if (!languages.some((l) => l.lang === locale)) {
locale = "en" locale = "en"
} }
// handle non-english locales dynamicActivate(locale)
if (locale !== "en") {
dynamicActivate(locale)
} else {
// fallback to en
activateLocale("en")
}
} }

View File

@@ -1,77 +0,0 @@
[
{
"lang": "ar",
"label": "العربية",
"e": "🇵🇸"
},
{
"lang": "de",
"label": "Deutsch",
"e": "🇩🇪"
},
{
"lang": "en",
"label": "English",
"e": "🇺🇸"
},
{
"lang": "es",
"label": "Español",
"e": "🇲🇽"
},
{
"lang": "fr",
"label": "Français",
"e": "🇫🇷"
},
{
"lang": "it",
"label": "Italiano",
"e": "🇮🇹"
},
{
"lang": "ja",
"label": "日本語",
"e": "🇯🇵"
},
{
"lang": "ko",
"label": "한국어",
"e": "🇰🇷"
},
{
"lang": "pt",
"label": "Português",
"e": "🇧🇷"
},
{
"lang": "tr",
"label": "Türkçe",
"e": "🇹🇷"
},
{
"lang": "ru",
"label": "Русский",
"e": "🇷🇺"
},
{
"lang": "uk",
"label": "Українська",
"e": "🇺🇦"
},
{
"lang": "vi",
"label": "Tiếng Việt",
"e": "🇻🇳"
},
{
"lang": "zh-CN",
"label": "简体中文",
"e": "🇨🇳"
},
{
"lang": "zh-HK",
"label": "繁體中文",
"e": "🇭🇰"
}
]

View File

@@ -0,0 +1,77 @@
export default [
{
lang: "ar",
label: "العربية",
e: "🇵🇸",
},
{
lang: "de",
label: "Deutsch",
e: "🇩🇪",
},
{
lang: "en",
label: "English",
e: "🇺🇸",
},
{
lang: "es",
label: "Español",
e: "🇲🇽",
},
{
lang: "fr",
label: "Français",
e: "🇫🇷",
},
{
lang: "it",
label: "Italiano",
e: "🇮🇹",
},
{
lang: "ja",
label: "日本語",
e: "🇯🇵",
},
{
lang: "ko",
label: "한국어",
e: "🇰🇷",
},
{
lang: "pt",
label: "Português",
e: "🇧🇷",
},
{
lang: "tr",
label: "Türkçe",
e: "🇹🇷",
},
{
lang: "ru",
label: "Русский",
e: "🇷🇺",
},
{
lang: "uk",
label: "Українська",
e: "🇺🇦",
},
{
lang: "vi",
label: "Tiếng Việt",
e: "🇻🇳",
},
{
lang: "zh-CN",
label: "简体中文",
e: "🇨🇳",
},
{
lang: "zh-HK",
label: "繁體中文",
e: "🇭🇰",
},
] as const

View File

@@ -281,7 +281,7 @@ msgstr "استخدام القرص لـ {extraFsName}"
#: src/components/routes/system.tsx:386 #: src/components/routes/system.tsx:386
msgid "Docker CPU Usage" msgid "Docker CPU Usage"
msgstr "استخدام وحدة المعالجة المركزية لـ Docker" msgstr "استخدام CPU لـ Docker"
#: src/components/routes/system.tsx:407 #: src/components/routes/system.tsx:407
msgid "Docker Memory Usage" msgid "Docker Memory Usage"
@@ -571,7 +571,7 @@ msgstr "المفتاح العام"
#. Context is disk read #. Context is disk read
#: src/components/charts/area-chart.tsx:56 #: src/components/charts/area-chart.tsx:56
#: src/components/charts/area-chart.tsx:65 #: src/components/charts/area-chart.tsx:66
msgid "Read" msgid "Read"
msgstr "قراءة" msgstr "قراءة"
@@ -791,7 +791,7 @@ msgstr "إشعارات Webhook / Push"
#. Context is disk write #. Context is disk write
#: src/components/charts/area-chart.tsx:55 #: src/components/charts/area-chart.tsx:55
#: src/components/charts/area-chart.tsx:66 #: src/components/charts/area-chart.tsx:65
msgid "Write" msgid "Write"
msgstr "كتابة" msgstr "كتابة"
@@ -806,4 +806,3 @@ msgstr "تكوين YAML"
#: src/components/routes/settings/layout.tsx:34 #: src/components/routes/settings/layout.tsx:34
msgid "Your user settings have been updated." msgid "Your user settings have been updated."
msgstr "تم تحديث إعدادات المستخدم الخاصة بك." msgstr "تم تحديث إعدادات المستخدم الخاصة بك."

View File

@@ -571,7 +571,7 @@ msgstr "Schlüssel"
#. Context is disk read #. Context is disk read
#: src/components/charts/area-chart.tsx:56 #: src/components/charts/area-chart.tsx:56
#: src/components/charts/area-chart.tsx:65 #: src/components/charts/area-chart.tsx:66
msgid "Read" msgid "Read"
msgstr "Lesen" msgstr "Lesen"
@@ -791,7 +791,7 @@ msgstr "Webhook / Push-Benachrichtigungen"
#. Context is disk write #. Context is disk write
#: src/components/charts/area-chart.tsx:55 #: src/components/charts/area-chart.tsx:55
#: src/components/charts/area-chart.tsx:66 #: src/components/charts/area-chart.tsx:65
msgid "Write" msgid "Write"
msgstr "Schreiben" msgstr "Schreiben"
@@ -806,4 +806,3 @@ msgstr "YAML-Konfiguration"
#: src/components/routes/settings/layout.tsx:34 #: src/components/routes/settings/layout.tsx:34
msgid "Your user settings have been updated." msgid "Your user settings have been updated."
msgstr "Ihre Benutzereinstellungen wurden aktualisiert." msgstr "Ihre Benutzereinstellungen wurden aktualisiert."

View File

@@ -566,7 +566,7 @@ msgstr "Public Key"
#. Context is disk read #. Context is disk read
#: src/components/charts/area-chart.tsx:56 #: src/components/charts/area-chart.tsx:56
#: src/components/charts/area-chart.tsx:65 #: src/components/charts/area-chart.tsx:66
msgid "Read" msgid "Read"
msgstr "Read" msgstr "Read"
@@ -786,7 +786,7 @@ msgstr "Webhook / Push notifications"
#. Context is disk write #. Context is disk write
#: src/components/charts/area-chart.tsx:55 #: src/components/charts/area-chart.tsx:55
#: src/components/charts/area-chart.tsx:66 #: src/components/charts/area-chart.tsx:65
msgid "Write" msgid "Write"
msgstr "Write" msgstr "Write"

View File

@@ -571,7 +571,7 @@ msgstr "Clave Pública"
#. Context is disk read #. Context is disk read
#: src/components/charts/area-chart.tsx:56 #: src/components/charts/area-chart.tsx:56
#: src/components/charts/area-chart.tsx:65 #: src/components/charts/area-chart.tsx:66
msgid "Read" msgid "Read"
msgstr "Lectura" msgstr "Lectura"
@@ -791,7 +791,7 @@ msgstr "Notificaciones Webhook / Push"
#. Context is disk write #. Context is disk write
#: src/components/charts/area-chart.tsx:55 #: src/components/charts/area-chart.tsx:55
#: src/components/charts/area-chart.tsx:66 #: src/components/charts/area-chart.tsx:65
msgid "Write" msgid "Write"
msgstr "Escritura" msgstr "Escritura"
@@ -806,4 +806,3 @@ msgstr "Configuración YAML"
#: src/components/routes/settings/layout.tsx:34 #: src/components/routes/settings/layout.tsx:34
msgid "Your user settings have been updated." msgid "Your user settings have been updated."
msgstr "Su configuración de usuario ha sido actualizada." msgstr "Su configuración de usuario ha sido actualizada."

View File

@@ -571,7 +571,7 @@ msgstr "Clé publique"
#. Context is disk read #. Context is disk read
#: src/components/charts/area-chart.tsx:56 #: src/components/charts/area-chart.tsx:56
#: src/components/charts/area-chart.tsx:65 #: src/components/charts/area-chart.tsx:66
msgid "Read" msgid "Read"
msgstr "Lecture" msgstr "Lecture"
@@ -791,7 +791,7 @@ msgstr "Notifications Webhook / Push"
#. Context is disk write #. Context is disk write
#: src/components/charts/area-chart.tsx:55 #: src/components/charts/area-chart.tsx:55
#: src/components/charts/area-chart.tsx:66 #: src/components/charts/area-chart.tsx:65
msgid "Write" msgid "Write"
msgstr "Écriture" msgstr "Écriture"
@@ -806,4 +806,3 @@ msgstr "Configuration YAML"
#: src/components/routes/settings/layout.tsx:34 #: src/components/routes/settings/layout.tsx:34
msgid "Your user settings have been updated." msgid "Your user settings have been updated."
msgstr "Vos paramètres utilisateur ont été mis à jour." msgstr "Vos paramètres utilisateur ont été mis à jour."

View File

@@ -571,7 +571,7 @@ msgstr "Chiave Pub"
#. Context is disk read #. Context is disk read
#: src/components/charts/area-chart.tsx:56 #: src/components/charts/area-chart.tsx:56
#: src/components/charts/area-chart.tsx:65 #: src/components/charts/area-chart.tsx:66
msgid "Read" msgid "Read"
msgstr "Lettura" msgstr "Lettura"
@@ -791,7 +791,7 @@ msgstr "Notifiche Webhook / Push"
#. Context is disk write #. Context is disk write
#: src/components/charts/area-chart.tsx:55 #: src/components/charts/area-chart.tsx:55
#: src/components/charts/area-chart.tsx:66 #: src/components/charts/area-chart.tsx:65
msgid "Write" msgid "Write"
msgstr "Scrittura" msgstr "Scrittura"
@@ -806,4 +806,3 @@ msgstr "Configurazione YAML"
#: src/components/routes/settings/layout.tsx:34 #: src/components/routes/settings/layout.tsx:34
msgid "Your user settings have been updated." msgid "Your user settings have been updated."
msgstr "Le impostazioni utente sono state aggiornate." msgstr "Le impostazioni utente sono state aggiornate."

View File

@@ -571,7 +571,7 @@ msgstr "公開鍵"
#. Context is disk read #. Context is disk read
#: src/components/charts/area-chart.tsx:56 #: src/components/charts/area-chart.tsx:56
#: src/components/charts/area-chart.tsx:65 #: src/components/charts/area-chart.tsx:66
msgid "Read" msgid "Read"
msgstr "読み取り" msgstr "読み取り"
@@ -791,7 +791,7 @@ msgstr "Webhook / プッシュ通知"
#. Context is disk write #. Context is disk write
#: src/components/charts/area-chart.tsx:55 #: src/components/charts/area-chart.tsx:55
#: src/components/charts/area-chart.tsx:66 #: src/components/charts/area-chart.tsx:65
msgid "Write" msgid "Write"
msgstr "書き込み" msgstr "書き込み"
@@ -806,4 +806,3 @@ msgstr "YAML設定"
#: src/components/routes/settings/layout.tsx:34 #: src/components/routes/settings/layout.tsx:34
msgid "Your user settings have been updated." msgid "Your user settings have been updated."
msgstr "ユーザー設定が更新されました。" msgstr "ユーザー設定が更新されました。"

View File

@@ -571,7 +571,7 @@ msgstr "공개 키"
#. Context is disk read #. Context is disk read
#: src/components/charts/area-chart.tsx:56 #: src/components/charts/area-chart.tsx:56
#: src/components/charts/area-chart.tsx:65 #: src/components/charts/area-chart.tsx:66
msgid "Read" msgid "Read"
msgstr "읽기" msgstr "읽기"
@@ -791,7 +791,7 @@ msgstr "Webhook / 푸시 알림"
#. Context is disk write #. Context is disk write
#: src/components/charts/area-chart.tsx:55 #: src/components/charts/area-chart.tsx:55
#: src/components/charts/area-chart.tsx:66 #: src/components/charts/area-chart.tsx:65
msgid "Write" msgid "Write"
msgstr "쓰기" msgstr "쓰기"
@@ -806,4 +806,3 @@ msgstr "YAML 구성"
#: src/components/routes/settings/layout.tsx:34 #: src/components/routes/settings/layout.tsx:34
msgid "Your user settings have been updated." msgid "Your user settings have been updated."
msgstr "사용자 설정이 업데이트되었습니다." msgstr "사용자 설정이 업데이트되었습니다."

View File

@@ -571,7 +571,7 @@ msgstr "Chave Pública"
#. Context is disk read #. Context is disk read
#: src/components/charts/area-chart.tsx:56 #: src/components/charts/area-chart.tsx:56
#: src/components/charts/area-chart.tsx:65 #: src/components/charts/area-chart.tsx:66
msgid "Read" msgid "Read"
msgstr "Ler" msgstr "Ler"
@@ -791,7 +791,7 @@ msgstr "Notificações Webhook / Push"
#. Context is disk write #. Context is disk write
#: src/components/charts/area-chart.tsx:55 #: src/components/charts/area-chart.tsx:55
#: src/components/charts/area-chart.tsx:66 #: src/components/charts/area-chart.tsx:65
msgid "Write" msgid "Write"
msgstr "Escrever" msgstr "Escrever"
@@ -806,4 +806,3 @@ msgstr "Configuração YAML"
#: src/components/routes/settings/layout.tsx:34 #: src/components/routes/settings/layout.tsx:34
msgid "Your user settings have been updated." msgid "Your user settings have been updated."
msgstr "As configurações do seu usuário foram atualizadas." msgstr "As configurações do seu usuário foram atualizadas."

View File

@@ -571,7 +571,7 @@ msgstr "Ключ"
#. Context is disk read #. Context is disk read
#: src/components/charts/area-chart.tsx:56 #: src/components/charts/area-chart.tsx:56
#: src/components/charts/area-chart.tsx:65 #: src/components/charts/area-chart.tsx:66
msgid "Read" msgid "Read"
msgstr "Чтение" msgstr "Чтение"
@@ -791,7 +791,7 @@ msgstr "Webhook / Push уведомления"
#. Context is disk write #. Context is disk write
#: src/components/charts/area-chart.tsx:55 #: src/components/charts/area-chart.tsx:55
#: src/components/charts/area-chart.tsx:66 #: src/components/charts/area-chart.tsx:65
msgid "Write" msgid "Write"
msgstr "Запись" msgstr "Запись"
@@ -806,4 +806,3 @@ msgstr "YAML конфигурация"
#: src/components/routes/settings/layout.tsx:34 #: src/components/routes/settings/layout.tsx:34
msgid "Your user settings have been updated." msgid "Your user settings have been updated."
msgstr "Ваши настройки пользователя были обновлены." msgstr "Ваши настройки пользователя были обновлены."

View File

@@ -571,7 +571,7 @@ msgstr "Genel Anahtar"
#. Context is disk read #. Context is disk read
#: src/components/charts/area-chart.tsx:56 #: src/components/charts/area-chart.tsx:56
#: src/components/charts/area-chart.tsx:65 #: src/components/charts/area-chart.tsx:66
msgid "Read" msgid "Read"
msgstr "Oku" msgstr "Oku"
@@ -791,7 +791,7 @@ msgstr "Webhook / Anlık bildirimler"
#. Context is disk write #. Context is disk write
#: src/components/charts/area-chart.tsx:55 #: src/components/charts/area-chart.tsx:55
#: src/components/charts/area-chart.tsx:66 #: src/components/charts/area-chart.tsx:65
msgid "Write" msgid "Write"
msgstr "Yaz" msgstr "Yaz"
@@ -806,4 +806,3 @@ msgstr "YAML Yapılandırması"
#: src/components/routes/settings/layout.tsx:34 #: src/components/routes/settings/layout.tsx:34
msgid "Your user settings have been updated." msgid "Your user settings have been updated."
msgstr "Kullanıcı ayarlarınız güncellendi." msgstr "Kullanıcı ayarlarınız güncellendi."

View File

@@ -571,7 +571,7 @@ msgstr "Ключ"
#. Context is disk read #. Context is disk read
#: src/components/charts/area-chart.tsx:56 #: src/components/charts/area-chart.tsx:56
#: src/components/charts/area-chart.tsx:65 #: src/components/charts/area-chart.tsx:66
msgid "Read" msgid "Read"
msgstr "Читання" msgstr "Читання"
@@ -791,7 +791,7 @@ msgstr "Webhook / Push сповіщення"
#. Context is disk write #. Context is disk write
#: src/components/charts/area-chart.tsx:55 #: src/components/charts/area-chart.tsx:55
#: src/components/charts/area-chart.tsx:66 #: src/components/charts/area-chart.tsx:65
msgid "Write" msgid "Write"
msgstr "Запис" msgstr "Запис"
@@ -806,4 +806,3 @@ msgstr "Конфігурація YAML"
#: src/components/routes/settings/layout.tsx:34 #: src/components/routes/settings/layout.tsx:34
msgid "Your user settings have been updated." msgid "Your user settings have been updated."
msgstr "Ваші налаштування користувача були оновлені." msgstr "Ваші налаштування користувача були оновлені."

View File

@@ -571,7 +571,7 @@ msgstr "Khóa"
#. Context is disk read #. Context is disk read
#: src/components/charts/area-chart.tsx:56 #: src/components/charts/area-chart.tsx:56
#: src/components/charts/area-chart.tsx:65 #: src/components/charts/area-chart.tsx:66
msgid "Read" msgid "Read"
msgstr "Đọc" msgstr "Đọc"
@@ -791,7 +791,7 @@ msgstr "Thông báo Webhook / Push"
#. Context is disk write #. Context is disk write
#: src/components/charts/area-chart.tsx:55 #: src/components/charts/area-chart.tsx:55
#: src/components/charts/area-chart.tsx:66 #: src/components/charts/area-chart.tsx:65
msgid "Write" msgid "Write"
msgstr "Ghi" msgstr "Ghi"
@@ -806,4 +806,3 @@ msgstr "Cấu hình YAML"
#: src/components/routes/settings/layout.tsx:34 #: src/components/routes/settings/layout.tsx:34
msgid "Your user settings have been updated." msgid "Your user settings have been updated."
msgstr "Cài đặt người dùng của bạn đã được cập nhật." msgstr "Cài đặt người dùng của bạn đã được cập nhật."

View File

@@ -571,7 +571,7 @@ msgstr "公钥"
#. Context is disk read #. Context is disk read
#: src/components/charts/area-chart.tsx:56 #: src/components/charts/area-chart.tsx:56
#: src/components/charts/area-chart.tsx:65 #: src/components/charts/area-chart.tsx:66
msgid "Read" msgid "Read"
msgstr "读取" msgstr "读取"
@@ -791,7 +791,7 @@ msgstr "Webhook / 推送通知"
#. Context is disk write #. Context is disk write
#: src/components/charts/area-chart.tsx:55 #: src/components/charts/area-chart.tsx:55
#: src/components/charts/area-chart.tsx:66 #: src/components/charts/area-chart.tsx:65
msgid "Write" msgid "Write"
msgstr "写入" msgstr "写入"
@@ -806,4 +806,3 @@ msgstr "YAML配置"
#: src/components/routes/settings/layout.tsx:34 #: src/components/routes/settings/layout.tsx:34
msgid "Your user settings have been updated." msgid "Your user settings have been updated."
msgstr "您的用户设置已更新。" msgstr "您的用户设置已更新。"

View File

@@ -571,7 +571,7 @@ msgstr "公鑰"
#. Context is disk read #. Context is disk read
#: src/components/charts/area-chart.tsx:56 #: src/components/charts/area-chart.tsx:56
#: src/components/charts/area-chart.tsx:65 #: src/components/charts/area-chart.tsx:66
msgid "Read" msgid "Read"
msgstr "讀取" msgstr "讀取"
@@ -791,7 +791,7 @@ msgstr "Webhook / 推送通知"
#. Context is disk write #. Context is disk write
#: src/components/charts/area-chart.tsx:55 #: src/components/charts/area-chart.tsx:55
#: src/components/charts/area-chart.tsx:66 #: src/components/charts/area-chart.tsx:65
msgid "Write" msgid "Write"
msgstr "寫入" msgstr "寫入"
@@ -806,4 +806,3 @@ msgstr "YAML配置"
#: src/components/routes/settings/layout.tsx:34 #: src/components/routes/settings/layout.tsx:34
msgid "Your user settings have been updated." msgid "Your user settings have been updated."
msgstr "您的用戶設置已更新。" msgstr "您的用戶設置已更新。"