mirror of
https://github.com/pengzhanbo/vuepress-theme-plume.git
synced 2026-04-23 10:58:13 +08:00
16 lines
354 B
TypeScript
16 lines
354 B
TypeScript
import { locales } from './locales/index.js'
|
|
import type { Langs, Locale } from './types.js'
|
|
|
|
function createTranslate(lang?: Langs) {
|
|
let current: Langs = lang || 'en-US'
|
|
|
|
return {
|
|
setLang: (lang: Langs) => {
|
|
current = lang
|
|
},
|
|
t: (key: keyof Locale) => locales[current][key],
|
|
}
|
|
}
|
|
|
|
export const { t, setLang } = createTranslate()
|