/
githubmirror
/
marktext
Обзор
Документация
Войти
/
githubmirror
/
marktext
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
packages/muya/src/i18n/index.ts
35 строк
827 B
Ran Luo
refactor(muya): mark core/state/selection/inline-renderer internals private (#4541)
16 июн 2026, 17:42
Не верифицирован
16 июн 2026, 17:42
23edbf3
Код
Авторство
О чём код?
import type { Muya } from '../muya'; import type { ILocale } from './types'; import { en } from '../locales/en'; class I18n { public lang: string; private _resources: Record<string, ILocale['resource']>; constructor(_muya: Muya, object: ILocale) { const { name, resource } = object || en; this.lang = name; this._resources = { [name]: resource, }; } t(key: string): string { const { lang } = this; const resources = this._resources; return resources?.[lang]?.[key] || resources?.en?.[key] || key; } locale(object: ILocale) { const { name, resource } = object; this.lang = name; this._resources = { ...this._resources, [name]: resource, }; } } export default I18n;