提交 7a116803 编写于 作者: fxy060608's avatar fxy060608

chore(i18n): export Formatter

上级 ad071b8b
......@@ -152,7 +152,7 @@ class I18n {
}
this.formater = formater || defaultFormatter;
this.messages = messages || {};
this.setLocale(locale);
this.setLocale(locale || LOCALE_EN);
if (watcher) {
this.watchLocale(watcher);
}
......@@ -292,6 +292,7 @@ function initVueI18n(locale = LOCALE_EN, messages = {}, fallbackLocale = LOCALE_
};
}
exports.Formatter = BaseFormatter;
exports.I18n = I18n;
exports.LOCALE_EN = LOCALE_EN;
exports.LOCALE_ES = LOCALE_ES;
......
export declare type BuiltInLocale = typeof LOCALE_ZH_HANS | typeof LOCALE_ZH_HANT | typeof LOCALE_EN | typeof LOCALE_FR | typeof LOCALE_ES;
export declare interface Formatter {
export declare class Formatter {
_caches: {
[key: string]: Array<Token>;
};
constructor();
interpolate(message: string, values?: Record<string, unknown> | Array<unknown>): Array<unknown>;
}
declare interface Formatter_2 {
interpolate: (message: string, values?: Record<string, unknown> | Array<unknown>) => Array<unknown>;
}
......@@ -24,7 +32,7 @@ export declare interface I18nOptions {
locale: BuiltInLocale;
fallbackLocale?: BuiltInLocale;
messages?: LocaleMessages;
formater?: Formatter;
formater?: Formatter_2;
watcher?: LocaleWatcher;
}
......@@ -52,4 +60,9 @@ export declare type LocaleMessages = {
export declare type LocaleWatcher = (newLocale: BuiltInLocale, oldLocale: BuiltInLocale) => void;
declare type Token = {
type: 'text' | 'named' | 'list' | 'unknown';
value: string;
};
export { }
......@@ -148,7 +148,7 @@ class I18n {
}
this.formater = formater || defaultFormatter;
this.messages = messages || {};
this.setLocale(locale);
this.setLocale(locale || LOCALE_EN);
if (watcher) {
this.watchLocale(watcher);
}
......@@ -288,4 +288,4 @@ function initVueI18n(locale = LOCALE_EN, messages = {}, fallbackLocale = LOCALE_
};
}
export { I18n, LOCALE_EN, LOCALE_ES, LOCALE_FR, LOCALE_ZH_HANS, LOCALE_ZH_HANT, initVueI18n };
export { BaseFormatter as Formatter, I18n, LOCALE_EN, LOCALE_ES, LOCALE_FR, LOCALE_ZH_HANS, LOCALE_ZH_HANT, initVueI18n };
......@@ -100,7 +100,7 @@ export class I18n {
}
this.formater = formater || defaultFormatter
this.messages = messages || {}
this.setLocale(locale)
this.setLocale(locale || LOCALE_EN)
if (watcher) {
this.watchLocale(watcher)
}
......
export * from './I18n'
export * from './vue-i18n'
export { default as Formatter } from './format'
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册