Files
NapCatQQ/.pnpm-store/v3/files/4a/b1287aa11ea09698692c298362af95dfd9d621eddd468047e19693b4199488bbcbd0b01ca00d04b25e5ffda89fddaf1a3d326a4cefdf989089ae760c44e33d
T
TanTan e311ca3275
Build NapCat Artifacts / Type Check & Test (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

33 lines
1.8 KiB
Plaintext

export type LocalizedStrings<K extends string, T extends LocalizedString> = {
[lang: string]: Record<K, T>;
};
/**
* Stores a mapping of localized strings. Can be used to find the
* closest available string for a given locale.
*/
export class LocalizedStringDictionary<K extends string = string, T extends LocalizedString = string> {
constructor(messages: LocalizedStrings<K, T>, defaultLocale?: string);
/** Returns a localized string for the given key and locale. */
getStringForLocale(key: K, locale: string): T;
/** Returns all localized strings for the given locale. */
getStringsForLocale(locale: string): Record<K, T>;
static getGlobalDictionaryForPackage<K extends string = string, T extends LocalizedString = string>(packageName: string): LocalizedStringDictionary<K, T> | null;
}
export type Variables = Record<string, string | number | boolean> | undefined;
export type LocalizedString = string | ((args: Variables, formatter?: LocalizedStringFormatter<any, any>) => string);
type InternalString = string | (() => string);
/**
* Formats localized strings from a LocalizedStringDictionary. Supports interpolating variables,
* selecting the correct pluralization, and formatting numbers for the locale.
*/
export class LocalizedStringFormatter<K extends string = string, T extends LocalizedString = string> {
constructor(locale: string, strings: LocalizedStringDictionary<K, T>);
/** Formats a localized string for the given key with the provided variables. */
format(key: K, variables?: Variables): string;
protected plural(count: number, options: Record<string, InternalString>, type?: Intl.PluralRuleType): string;
protected number(value: number): string;
protected select(options: Record<string, InternalString>, value: string): string;
}
//# sourceMappingURL=types.d.ts.map