chore: bootstrap hermes-ui skeleton from 0.6.29 snapshot
Import the client, server, skills, tests, and build scripts as the starting point for the rebuild, then trim the surfaces this project does not ship: Electron desktop packaging, the marketing website, and the ESP32 firmware tree. CI keeps the web build, e2e, lockfile, release, and Docker workflows. Rename the package and CLI entry points to hermes-ui, drop the prepare hook so npm ci no longer triggers a build, and drop the removed tsconfig and nodemon references. Rewrite AGENTS.md, ARCHITECTURE.md, DEVELOPMENT.md, and the READMEs so the documented package map and hard rules match this repository. reference_code/ is ignored: it is a read-only snapshot, not an input to the build.
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
import { createI18n } from 'vue-i18n'
|
||||
import { messages, supportedLocales } from './messages'
|
||||
import type { SupportedLocale } from './messages'
|
||||
|
||||
const saved = localStorage.getItem('hermes_locale')
|
||||
|
||||
function resolveLocale(saved: string | null): SupportedLocale {
|
||||
if (saved && (supportedLocales as readonly string[]).includes(saved)) {
|
||||
return saved as SupportedLocale
|
||||
}
|
||||
|
||||
function normalize(tag: string): SupportedLocale | null {
|
||||
const lower = tag.toLowerCase()
|
||||
if (lower.startsWith('zh')) {
|
||||
const isTraditional =
|
||||
lower.includes('hant') ||
|
||||
lower.includes('-tw') ||
|
||||
lower.includes('-hk') ||
|
||||
lower.includes('-mo')
|
||||
return isTraditional ? 'zh-TW' : 'zh'
|
||||
}
|
||||
const short = tag.slice(0, 2)
|
||||
if ((supportedLocales as readonly string[]).includes(tag)) return tag as SupportedLocale
|
||||
if ((supportedLocales as readonly string[]).includes(short)) return short as SupportedLocale
|
||||
return null
|
||||
}
|
||||
|
||||
for (const lang of navigator.languages) {
|
||||
const resolved = normalize(lang)
|
||||
if (resolved) return resolved
|
||||
}
|
||||
|
||||
return 'en'
|
||||
}
|
||||
|
||||
function setHtmlLang(locale: SupportedLocale) {
|
||||
document.documentElement.lang = locale
|
||||
}
|
||||
|
||||
const locale = resolveLocale(saved)
|
||||
setHtmlLang(locale)
|
||||
|
||||
export const i18n = createI18n({
|
||||
legacy: false,
|
||||
locale,
|
||||
fallbackLocale: 'en',
|
||||
messages,
|
||||
})
|
||||
|
||||
export function switchLocale(newLocale: string): void {
|
||||
;(i18n.global.locale as any).value = newLocale
|
||||
setHtmlLang(newLocale as SupportedLocale)
|
||||
}
|
||||
Reference in New Issue
Block a user