mirror of
https://github.com/fankes/beszel.git
synced 2025-10-20 02:09:28 +08:00
update translations
This commit is contained in:
@@ -2,7 +2,7 @@ import { LanguagesIcon } from "lucide-react"
|
||||
|
||||
import { Button } from "@/components/ui/button"
|
||||
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 { useLingui } from "@lingui/react"
|
||||
import { dynamicActivate } from "@/lib/i18n"
|
||||
|
@@ -8,7 +8,7 @@ import { UserSettings } from "@/types"
|
||||
import { saveSettings } from "./layout"
|
||||
import { useState } from "react"
|
||||
import { Trans } from "@lingui/macro"
|
||||
import languages from "../../../lib/languages.json"
|
||||
import languages from "@/lib/languages"
|
||||
import { dynamicActivate } from "@/lib/i18n"
|
||||
import { useLingui } from "@lingui/react"
|
||||
// import { setLang } from "@/lib/i18n"
|
||||
|
@@ -1,12 +1,10 @@
|
||||
import { $direction } from "./stores"
|
||||
import { i18n } 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 { messages as enMessages } from "../locales/en/en.ts"
|
||||
|
||||
console.log(languages)
|
||||
|
||||
// let locale = detect(fromUrl("lang"), 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
|
||||
export async function dynamicActivate(locale: string) {
|
||||
try {
|
||||
const { messages }: { messages: Messages } = await import(`../locales/${locale}/${locale}.ts`)
|
||||
activateLocale(locale, messages)
|
||||
localStorage.setItem("lang", locale)
|
||||
} catch (error) {
|
||||
console.error(`Error loading ${locale}`, error)
|
||||
activateLocale("en")
|
||||
if (locale == "en") {
|
||||
activateLocale(locale)
|
||||
} else {
|
||||
try {
|
||||
const { messages }: { messages: Messages } = await import(`../locales/${locale}/${locale}.ts`)
|
||||
activateLocale(locale, messages)
|
||||
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)) {
|
||||
locale = "en"
|
||||
}
|
||||
// handle non-english locales
|
||||
if (locale !== "en") {
|
||||
dynamicActivate(locale)
|
||||
} else {
|
||||
// fallback to en
|
||||
activateLocale("en")
|
||||
}
|
||||
dynamicActivate(locale)
|
||||
}
|
||||
|
@@ -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": "🇭🇰"
|
||||
}
|
||||
]
|
77
beszel/site/src/lib/languages.ts
Normal file
77
beszel/site/src/lib/languages.ts
Normal 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
|
@@ -281,7 +281,7 @@ msgstr "استخدام القرص لـ {extraFsName}"
|
||||
|
||||
#: src/components/routes/system.tsx:386
|
||||
msgid "Docker CPU Usage"
|
||||
msgstr "استخدام وحدة المعالجة المركزية لـ Docker"
|
||||
msgstr "استخدام CPU لـ Docker"
|
||||
|
||||
#: src/components/routes/system.tsx:407
|
||||
msgid "Docker Memory Usage"
|
||||
@@ -571,7 +571,7 @@ msgstr "المفتاح العام"
|
||||
|
||||
#. Context is disk read
|
||||
#: src/components/charts/area-chart.tsx:56
|
||||
#: src/components/charts/area-chart.tsx:65
|
||||
#: src/components/charts/area-chart.tsx:66
|
||||
msgid "Read"
|
||||
msgstr "قراءة"
|
||||
|
||||
@@ -791,7 +791,7 @@ msgstr "إشعارات Webhook / Push"
|
||||
|
||||
#. Context is disk write
|
||||
#: src/components/charts/area-chart.tsx:55
|
||||
#: src/components/charts/area-chart.tsx:66
|
||||
#: src/components/charts/area-chart.tsx:65
|
||||
msgid "Write"
|
||||
msgstr "كتابة"
|
||||
|
||||
@@ -806,4 +806,3 @@ msgstr "تكوين YAML"
|
||||
#: src/components/routes/settings/layout.tsx:34
|
||||
msgid "Your user settings have been updated."
|
||||
msgstr "تم تحديث إعدادات المستخدم الخاصة بك."
|
||||
|
||||
|
@@ -571,7 +571,7 @@ msgstr "Schlüssel"
|
||||
|
||||
#. Context is disk read
|
||||
#: src/components/charts/area-chart.tsx:56
|
||||
#: src/components/charts/area-chart.tsx:65
|
||||
#: src/components/charts/area-chart.tsx:66
|
||||
msgid "Read"
|
||||
msgstr "Lesen"
|
||||
|
||||
@@ -791,7 +791,7 @@ msgstr "Webhook / Push-Benachrichtigungen"
|
||||
|
||||
#. Context is disk write
|
||||
#: src/components/charts/area-chart.tsx:55
|
||||
#: src/components/charts/area-chart.tsx:66
|
||||
#: src/components/charts/area-chart.tsx:65
|
||||
msgid "Write"
|
||||
msgstr "Schreiben"
|
||||
|
||||
@@ -806,4 +806,3 @@ msgstr "YAML-Konfiguration"
|
||||
#: src/components/routes/settings/layout.tsx:34
|
||||
msgid "Your user settings have been updated."
|
||||
msgstr "Ihre Benutzereinstellungen wurden aktualisiert."
|
||||
|
||||
|
@@ -566,7 +566,7 @@ msgstr "Public Key"
|
||||
|
||||
#. Context is disk read
|
||||
#: src/components/charts/area-chart.tsx:56
|
||||
#: src/components/charts/area-chart.tsx:65
|
||||
#: src/components/charts/area-chart.tsx:66
|
||||
msgid "Read"
|
||||
msgstr "Read"
|
||||
|
||||
@@ -786,7 +786,7 @@ msgstr "Webhook / Push notifications"
|
||||
|
||||
#. Context is disk write
|
||||
#: src/components/charts/area-chart.tsx:55
|
||||
#: src/components/charts/area-chart.tsx:66
|
||||
#: src/components/charts/area-chart.tsx:65
|
||||
msgid "Write"
|
||||
msgstr "Write"
|
||||
|
||||
|
@@ -571,7 +571,7 @@ msgstr "Clave Pública"
|
||||
|
||||
#. Context is disk read
|
||||
#: src/components/charts/area-chart.tsx:56
|
||||
#: src/components/charts/area-chart.tsx:65
|
||||
#: src/components/charts/area-chart.tsx:66
|
||||
msgid "Read"
|
||||
msgstr "Lectura"
|
||||
|
||||
@@ -791,7 +791,7 @@ msgstr "Notificaciones Webhook / Push"
|
||||
|
||||
#. Context is disk write
|
||||
#: src/components/charts/area-chart.tsx:55
|
||||
#: src/components/charts/area-chart.tsx:66
|
||||
#: src/components/charts/area-chart.tsx:65
|
||||
msgid "Write"
|
||||
msgstr "Escritura"
|
||||
|
||||
@@ -806,4 +806,3 @@ msgstr "Configuración YAML"
|
||||
#: src/components/routes/settings/layout.tsx:34
|
||||
msgid "Your user settings have been updated."
|
||||
msgstr "Su configuración de usuario ha sido actualizada."
|
||||
|
||||
|
@@ -571,7 +571,7 @@ msgstr "Clé publique"
|
||||
|
||||
#. Context is disk read
|
||||
#: src/components/charts/area-chart.tsx:56
|
||||
#: src/components/charts/area-chart.tsx:65
|
||||
#: src/components/charts/area-chart.tsx:66
|
||||
msgid "Read"
|
||||
msgstr "Lecture"
|
||||
|
||||
@@ -791,7 +791,7 @@ msgstr "Notifications Webhook / Push"
|
||||
|
||||
#. Context is disk write
|
||||
#: src/components/charts/area-chart.tsx:55
|
||||
#: src/components/charts/area-chart.tsx:66
|
||||
#: src/components/charts/area-chart.tsx:65
|
||||
msgid "Write"
|
||||
msgstr "Écriture"
|
||||
|
||||
@@ -806,4 +806,3 @@ msgstr "Configuration YAML"
|
||||
#: src/components/routes/settings/layout.tsx:34
|
||||
msgid "Your user settings have been updated."
|
||||
msgstr "Vos paramètres utilisateur ont été mis à jour."
|
||||
|
||||
|
@@ -571,7 +571,7 @@ msgstr "Chiave Pub"
|
||||
|
||||
#. Context is disk read
|
||||
#: src/components/charts/area-chart.tsx:56
|
||||
#: src/components/charts/area-chart.tsx:65
|
||||
#: src/components/charts/area-chart.tsx:66
|
||||
msgid "Read"
|
||||
msgstr "Lettura"
|
||||
|
||||
@@ -791,7 +791,7 @@ msgstr "Notifiche Webhook / Push"
|
||||
|
||||
#. Context is disk write
|
||||
#: src/components/charts/area-chart.tsx:55
|
||||
#: src/components/charts/area-chart.tsx:66
|
||||
#: src/components/charts/area-chart.tsx:65
|
||||
msgid "Write"
|
||||
msgstr "Scrittura"
|
||||
|
||||
@@ -806,4 +806,3 @@ msgstr "Configurazione YAML"
|
||||
#: src/components/routes/settings/layout.tsx:34
|
||||
msgid "Your user settings have been updated."
|
||||
msgstr "Le impostazioni utente sono state aggiornate."
|
||||
|
||||
|
@@ -571,7 +571,7 @@ msgstr "公開鍵"
|
||||
|
||||
#. Context is disk read
|
||||
#: src/components/charts/area-chart.tsx:56
|
||||
#: src/components/charts/area-chart.tsx:65
|
||||
#: src/components/charts/area-chart.tsx:66
|
||||
msgid "Read"
|
||||
msgstr "読み取り"
|
||||
|
||||
@@ -791,7 +791,7 @@ msgstr "Webhook / プッシュ通知"
|
||||
|
||||
#. Context is disk write
|
||||
#: src/components/charts/area-chart.tsx:55
|
||||
#: src/components/charts/area-chart.tsx:66
|
||||
#: src/components/charts/area-chart.tsx:65
|
||||
msgid "Write"
|
||||
msgstr "書き込み"
|
||||
|
||||
@@ -806,4 +806,3 @@ msgstr "YAML設定"
|
||||
#: src/components/routes/settings/layout.tsx:34
|
||||
msgid "Your user settings have been updated."
|
||||
msgstr "ユーザー設定が更新されました。"
|
||||
|
||||
|
@@ -571,7 +571,7 @@ msgstr "공개 키"
|
||||
|
||||
#. Context is disk read
|
||||
#: src/components/charts/area-chart.tsx:56
|
||||
#: src/components/charts/area-chart.tsx:65
|
||||
#: src/components/charts/area-chart.tsx:66
|
||||
msgid "Read"
|
||||
msgstr "읽기"
|
||||
|
||||
@@ -791,7 +791,7 @@ msgstr "Webhook / 푸시 알림"
|
||||
|
||||
#. Context is disk write
|
||||
#: src/components/charts/area-chart.tsx:55
|
||||
#: src/components/charts/area-chart.tsx:66
|
||||
#: src/components/charts/area-chart.tsx:65
|
||||
msgid "Write"
|
||||
msgstr "쓰기"
|
||||
|
||||
@@ -806,4 +806,3 @@ msgstr "YAML 구성"
|
||||
#: src/components/routes/settings/layout.tsx:34
|
||||
msgid "Your user settings have been updated."
|
||||
msgstr "사용자 설정이 업데이트되었습니다."
|
||||
|
||||
|
@@ -571,7 +571,7 @@ msgstr "Chave Pública"
|
||||
|
||||
#. Context is disk read
|
||||
#: src/components/charts/area-chart.tsx:56
|
||||
#: src/components/charts/area-chart.tsx:65
|
||||
#: src/components/charts/area-chart.tsx:66
|
||||
msgid "Read"
|
||||
msgstr "Ler"
|
||||
|
||||
@@ -791,7 +791,7 @@ msgstr "Notificações Webhook / Push"
|
||||
|
||||
#. Context is disk write
|
||||
#: src/components/charts/area-chart.tsx:55
|
||||
#: src/components/charts/area-chart.tsx:66
|
||||
#: src/components/charts/area-chart.tsx:65
|
||||
msgid "Write"
|
||||
msgstr "Escrever"
|
||||
|
||||
@@ -806,4 +806,3 @@ msgstr "Configuração YAML"
|
||||
#: src/components/routes/settings/layout.tsx:34
|
||||
msgid "Your user settings have been updated."
|
||||
msgstr "As configurações do seu usuário foram atualizadas."
|
||||
|
||||
|
@@ -571,7 +571,7 @@ msgstr "Ключ"
|
||||
|
||||
#. Context is disk read
|
||||
#: src/components/charts/area-chart.tsx:56
|
||||
#: src/components/charts/area-chart.tsx:65
|
||||
#: src/components/charts/area-chart.tsx:66
|
||||
msgid "Read"
|
||||
msgstr "Чтение"
|
||||
|
||||
@@ -791,7 +791,7 @@ msgstr "Webhook / Push уведомления"
|
||||
|
||||
#. Context is disk write
|
||||
#: src/components/charts/area-chart.tsx:55
|
||||
#: src/components/charts/area-chart.tsx:66
|
||||
#: src/components/charts/area-chart.tsx:65
|
||||
msgid "Write"
|
||||
msgstr "Запись"
|
||||
|
||||
@@ -806,4 +806,3 @@ msgstr "YAML конфигурация"
|
||||
#: src/components/routes/settings/layout.tsx:34
|
||||
msgid "Your user settings have been updated."
|
||||
msgstr "Ваши настройки пользователя были обновлены."
|
||||
|
||||
|
@@ -571,7 +571,7 @@ msgstr "Genel Anahtar"
|
||||
|
||||
#. Context is disk read
|
||||
#: src/components/charts/area-chart.tsx:56
|
||||
#: src/components/charts/area-chart.tsx:65
|
||||
#: src/components/charts/area-chart.tsx:66
|
||||
msgid "Read"
|
||||
msgstr "Oku"
|
||||
|
||||
@@ -791,7 +791,7 @@ msgstr "Webhook / Anlık bildirimler"
|
||||
|
||||
#. Context is disk write
|
||||
#: src/components/charts/area-chart.tsx:55
|
||||
#: src/components/charts/area-chart.tsx:66
|
||||
#: src/components/charts/area-chart.tsx:65
|
||||
msgid "Write"
|
||||
msgstr "Yaz"
|
||||
|
||||
@@ -806,4 +806,3 @@ msgstr "YAML Yapılandırması"
|
||||
#: src/components/routes/settings/layout.tsx:34
|
||||
msgid "Your user settings have been updated."
|
||||
msgstr "Kullanıcı ayarlarınız güncellendi."
|
||||
|
||||
|
@@ -571,7 +571,7 @@ msgstr "Ключ"
|
||||
|
||||
#. Context is disk read
|
||||
#: src/components/charts/area-chart.tsx:56
|
||||
#: src/components/charts/area-chart.tsx:65
|
||||
#: src/components/charts/area-chart.tsx:66
|
||||
msgid "Read"
|
||||
msgstr "Читання"
|
||||
|
||||
@@ -791,7 +791,7 @@ msgstr "Webhook / Push сповіщення"
|
||||
|
||||
#. Context is disk write
|
||||
#: src/components/charts/area-chart.tsx:55
|
||||
#: src/components/charts/area-chart.tsx:66
|
||||
#: src/components/charts/area-chart.tsx:65
|
||||
msgid "Write"
|
||||
msgstr "Запис"
|
||||
|
||||
@@ -806,4 +806,3 @@ msgstr "Конфігурація YAML"
|
||||
#: src/components/routes/settings/layout.tsx:34
|
||||
msgid "Your user settings have been updated."
|
||||
msgstr "Ваші налаштування користувача були оновлені."
|
||||
|
||||
|
@@ -571,7 +571,7 @@ msgstr "Khóa"
|
||||
|
||||
#. Context is disk read
|
||||
#: src/components/charts/area-chart.tsx:56
|
||||
#: src/components/charts/area-chart.tsx:65
|
||||
#: src/components/charts/area-chart.tsx:66
|
||||
msgid "Read"
|
||||
msgstr "Đọc"
|
||||
|
||||
@@ -791,7 +791,7 @@ msgstr "Thông báo Webhook / Push"
|
||||
|
||||
#. Context is disk write
|
||||
#: src/components/charts/area-chart.tsx:55
|
||||
#: src/components/charts/area-chart.tsx:66
|
||||
#: src/components/charts/area-chart.tsx:65
|
||||
msgid "Write"
|
||||
msgstr "Ghi"
|
||||
|
||||
@@ -806,4 +806,3 @@ msgstr "Cấu hình YAML"
|
||||
#: src/components/routes/settings/layout.tsx:34
|
||||
msgid "Your user settings have been updated."
|
||||
msgstr "Cài đặt người dùng của bạn đã được cập nhật."
|
||||
|
||||
|
@@ -571,7 +571,7 @@ msgstr "公钥"
|
||||
|
||||
#. Context is disk read
|
||||
#: src/components/charts/area-chart.tsx:56
|
||||
#: src/components/charts/area-chart.tsx:65
|
||||
#: src/components/charts/area-chart.tsx:66
|
||||
msgid "Read"
|
||||
msgstr "读取"
|
||||
|
||||
@@ -791,7 +791,7 @@ msgstr "Webhook / 推送通知"
|
||||
|
||||
#. Context is disk write
|
||||
#: src/components/charts/area-chart.tsx:55
|
||||
#: src/components/charts/area-chart.tsx:66
|
||||
#: src/components/charts/area-chart.tsx:65
|
||||
msgid "Write"
|
||||
msgstr "写入"
|
||||
|
||||
@@ -806,4 +806,3 @@ msgstr "YAML配置"
|
||||
#: src/components/routes/settings/layout.tsx:34
|
||||
msgid "Your user settings have been updated."
|
||||
msgstr "您的用户设置已更新。"
|
||||
|
||||
|
@@ -571,7 +571,7 @@ msgstr "公鑰"
|
||||
|
||||
#. Context is disk read
|
||||
#: src/components/charts/area-chart.tsx:56
|
||||
#: src/components/charts/area-chart.tsx:65
|
||||
#: src/components/charts/area-chart.tsx:66
|
||||
msgid "Read"
|
||||
msgstr "讀取"
|
||||
|
||||
@@ -791,7 +791,7 @@ msgstr "Webhook / 推送通知"
|
||||
|
||||
#. Context is disk write
|
||||
#: src/components/charts/area-chart.tsx:55
|
||||
#: src/components/charts/area-chart.tsx:66
|
||||
#: src/components/charts/area-chart.tsx:65
|
||||
msgid "Write"
|
||||
msgstr "寫入"
|
||||
|
||||
@@ -806,4 +806,3 @@ msgstr "YAML配置"
|
||||
#: src/components/routes/settings/layout.tsx:34
|
||||
msgid "Your user settings have been updated."
|
||||
msgstr "您的用戶設置已更新。"
|
||||
|
||||
|
Reference in New Issue
Block a user