ember-intl
Version:
Internationalization for Ember projects
63 lines • 2.9 kB
TypeScript
import Service from '@ember/service';
import type { FormatDateParameters, FormatDateRangeParameters, FormatListParameters, FormatMessageParameters, FormatNumberParameters, FormatRelativeTimeParameters, Formats, FormatTimeParameters, OnErrorFn } from '../-private/formatjs/index.ts';
import { type TranslationJson } from '../-private/utils/translations.ts';
export type { Formats };
type OnFormatjsError = (error: Parameters<OnErrorFn>[0]) => void;
type OnMissingTranslation = (key: string, locales: string[], data?: Record<string, unknown>) => string;
export default class IntlService extends Service {
private _intls;
private _locale?;
private _cache;
private _formats;
private _onFormatjsError;
private _onMissingTranslation;
private _timer?;
get locales(): string[];
get primaryLocale(): string | undefined;
addTranslations(locale: string, translations: TranslationJson): void;
private createIntl;
exists(key: string, locale?: string | string[]): boolean;
formatDate(value: FormatDateParameters[0] | undefined | null, options?: FormatDateParameters[1] & {
locale?: string;
}): string;
formatDateRange(from: FormatDateRangeParameters[0] | undefined | null, to: FormatDateRangeParameters[1] | undefined | null, options?: FormatDateRangeParameters[2] & {
locale?: string;
}): string;
formatList(value: FormatListParameters[0] | undefined | null, options?: FormatListParameters[1] & {
locale?: string;
}): string;
formatMessage(value: FormatMessageParameters[0] | string | undefined | null, options?: FormatMessageParameters[1] & {
htmlSafe?: boolean;
locale?: string;
}): string;
formatNumber(value: FormatNumberParameters[0] | undefined | null, options?: FormatNumberParameters[1] & {
locale?: string;
}): string;
formatRelativeTime(value: FormatRelativeTimeParameters[0] | undefined | null, options?: FormatRelativeTimeParameters[2] & {
locale?: string;
unit?: FormatRelativeTimeParameters[1];
}): string;
formatTime(value: FormatTimeParameters[0] | undefined | null, options?: FormatTimeParameters[1] & {
locale?: string;
}): string;
private getIntl;
private getIntlShape;
getTranslation(key: string, locale: string): string | undefined;
setFormats(formats: Formats): void;
setLocale(locale: string | string[]): void;
setOnFormatjsError(onFormatjsError: OnFormatjsError): void;
setOnMissingTranslation(onMissingTranslation: OnMissingTranslation): void;
t(key: string, options?: FormatMessageParameters[1] & {
htmlSafe?: boolean;
locale?: string;
}): string;
private updateDocumentLanguage;
private updateIntl;
willDestroy(): void;
}
declare module '@ember/service' {
interface Registry {
intl: IntlService;
}
}
//# sourceMappingURL=intl.d.ts.map