import moment from 'moment'; import type { LocaleConfig, TranslateFn } from './types'; type StrictLocale = 'zh_CN' | 'en_US'; export declare class LocaleController { locales: Record; fns: Record; defaultLocale: StrictLocale; currentLocale: StrictLocale; /** * 是否锁定了locale */ private localeLocked; private translator; localeChangeListeners: ((locale: StrictLocale) => void)[]; constructor(); getMomentLocale: () => moment.Locale; /** * 设置并锁定locale, 用于不支持国际化的场景 * @param locale */ setLockedLocale: (locale: StrictLocale) => void; /** * 给html元素设置正确的lang */ setDocLang: () => void; registerLocale: (name: StrictLocale, config: LocaleConfig) => void; extendLocale: (name: StrictLocale, config: LocaleConfig) => void; getDefaultLocale(): StrictLocale; /** * 设置默认的locale */ setDefaultLocale: (locale: string) => void; makeTranslator: (_locale?: string) => TranslateFn; getTranslator: () => TranslateFn; translate: TranslateFn; addChangeListener: (listener: (locale: StrictLocale) => void) => void; private initCurrentLocale; setCurrentLocale: (locale: StrictLocale) => void; getCurrentLocale: () => StrictLocale; /** * 判断当前是否是英文环境 */ isEnglish: () => boolean; formatLocale(locale?: string): StrictLocale | ''; /** * 获取cookie或者lc中的语言设置 * 注意, 旧页面里的zh-CN被写成了'zh_CN', 需要矫正 */ private getLocaleFromStorage; private getCookieKey; private getLocaleFromLang; private getBrowserLang; private format; private emitLocaleChange; } /** * 单例的国际化控制器 */ export declare const localeController: LocaleController; export declare const isEnglish: () => boolean; /** * @deprecated 请使用 `localeController.extendLocale` */ export declare const extendLocale: (name: StrictLocale, config: LocaleConfig) => void; /** * @deprecated 请使用 `localeController.setDefaultLocale` */ export declare const setDefaultLocale: (locale: string) => void; /** * @deprecated 请使用 `localeController.makeTranslator` */ export declare const makeTranslator: (_locale?: string) => TranslateFn; export declare const translate: TranslateFn; export declare const __: TranslateFn; export {};