33 lines
774 B
TypeScript
33 lines
774 B
TypeScript
|
|
import type { LocaleDefinition } from "@workspace/i18n"
|
||
|
|
|
||
|
|
export type AppLocale = "en" | "zh-Hans"
|
||
|
|
export type AppLocaleCountry = "CN" | "US"
|
||
|
|
|
||
|
|
export interface AppLocaleDefinition extends LocaleDefinition {
|
||
|
|
country: AppLocaleCountry
|
||
|
|
locale: AppLocale
|
||
|
|
}
|
||
|
|
|
||
|
|
export const DEFAULT_APP_LOCALE: AppLocale = "zh-Hans"
|
||
|
|
|
||
|
|
export const appLocales = [
|
||
|
|
{
|
||
|
|
country: "US",
|
||
|
|
direction: "ltr",
|
||
|
|
languageTag: "en-US",
|
||
|
|
label: "English",
|
||
|
|
locale: "en",
|
||
|
|
},
|
||
|
|
{
|
||
|
|
country: "CN",
|
||
|
|
direction: "ltr",
|
||
|
|
languageTag: "zh-CN",
|
||
|
|
label: "简体中文",
|
||
|
|
locale: "zh-Hans",
|
||
|
|
},
|
||
|
|
] as const satisfies readonly AppLocaleDefinition[]
|
||
|
|
|
||
|
|
export function isAppLocale(value: unknown): value is AppLocale {
|
||
|
|
return appLocales.some((definition) => definition.locale === value)
|
||
|
|
}
|