wip(app): i18n
This commit is contained in:
@@ -179,7 +179,7 @@ export function DialogSelectServer() {
|
||||
type="text"
|
||||
label={language.t("dialog.server.add.url")}
|
||||
hideLabel
|
||||
placeholder="http://localhost:4096"
|
||||
placeholder={language.t("dialog.server.add.placeholder")}
|
||||
value={store.url}
|
||||
onChange={(v) => {
|
||||
setStore("url", v)
|
||||
|
||||
@@ -2,13 +2,25 @@
|
||||
import { render } from "solid-js/web"
|
||||
import { AppBaseProviders, AppInterface } from "@/app"
|
||||
import { Platform, PlatformProvider } from "@/context/platform"
|
||||
import { dict as en } from "@/i18n/en"
|
||||
import { dict as zh } from "@/i18n/zh"
|
||||
import pkg from "../package.json"
|
||||
|
||||
const root = document.getElementById("root")
|
||||
if (import.meta.env.DEV && !(root instanceof HTMLElement)) {
|
||||
throw new Error(
|
||||
"Root element not found. Did you forget to add it to your index.html? Or maybe the id attribute got misspelled?",
|
||||
)
|
||||
const locale = (() => {
|
||||
if (typeof navigator !== "object") return "en" as const
|
||||
const languages = navigator.languages?.length ? navigator.languages : [navigator.language]
|
||||
for (const language of languages) {
|
||||
if (!language) continue
|
||||
if (language.toLowerCase().startsWith("zh")) return "zh" as const
|
||||
}
|
||||
return "en" as const
|
||||
})()
|
||||
|
||||
const key = "error.dev.rootNotFound" as const
|
||||
const message = locale === "zh" ? zh[key] ?? en[key] : en[key]
|
||||
throw new Error(message)
|
||||
}
|
||||
|
||||
const platform: Platform = {
|
||||
|
||||
@@ -212,6 +212,7 @@ export const dict = {
|
||||
"dialog.server.empty": "No servers yet",
|
||||
"dialog.server.add.title": "Add a server",
|
||||
"dialog.server.add.url": "Server URL",
|
||||
"dialog.server.add.placeholder": "http://localhost:4096",
|
||||
"dialog.server.add.error": "Could not connect to server",
|
||||
"dialog.server.add.checking": "Checking...",
|
||||
"dialog.server.add.button": "Add",
|
||||
@@ -310,6 +311,9 @@ export const dict = {
|
||||
"error.page.report.discord": "on Discord",
|
||||
"error.page.version": "Version: {{version}}",
|
||||
|
||||
"error.dev.rootNotFound":
|
||||
"Root element not found. Did you forget to add it to your index.html? Or maybe the id attribute got misspelled?",
|
||||
|
||||
"error.globalSync.connectFailed": "Could not connect to server. Is there a server running at `{{url}}`?",
|
||||
|
||||
"error.chain.unknown": "Unknown error",
|
||||
|
||||
@@ -211,6 +211,7 @@ export const dict = {
|
||||
"dialog.server.empty": "暂无服务器",
|
||||
"dialog.server.add.title": "添加服务器",
|
||||
"dialog.server.add.url": "服务器 URL",
|
||||
"dialog.server.add.placeholder": "http://localhost:4096",
|
||||
"dialog.server.add.error": "无法连接到服务器",
|
||||
"dialog.server.add.checking": "检查中...",
|
||||
"dialog.server.add.button": "添加",
|
||||
@@ -309,6 +310,8 @@ export const dict = {
|
||||
"error.page.report.discord": "在 Discord 上",
|
||||
"error.page.version": "版本: {{version}}",
|
||||
|
||||
"error.dev.rootNotFound": "未找到根元素。你是不是忘了把它添加到 index.html? 或者 id 属性拼写错了?",
|
||||
|
||||
"error.globalSync.connectFailed": "无法连接到服务器。是否有服务器正在 `{{url}}` 运行?",
|
||||
|
||||
"error.chain.unknown": "未知错误",
|
||||
|
||||
Reference in New Issue
Block a user