declare namespace I18n { type Scope = string | string[] let defaultLocale: string let locale: string let defaultSeparator: string let placeholder: RegExp let fallbacks: boolean let missingBehaviour: 'message' | 'guess' let missingTranslationPrefix: string // tslint:disable-next-line prefer-declare-function let missingTranslation: ( scope: string, options?: TranslateOptions ) => string | null | undefined // tslint:disable-next-line prefer-declare-function let missingPlaceholder: ( placeholder: string, message: string, options?: InterpolateOptions ) => string | null | undefined // tslint:disable-next-line prefer-declare-function let nullPlaceholder: ( placeholder: string, message: string, options?: InterpolateOptions ) => string | null | undefined let translations: { [locale: string]: object } let locales: { [key: string]: string | string[] | ((locale: string) => string | string[]) } let pluralization: { [locale: string]: (count: number) => string[] } function reset(): void function currentLocale(): string interface InterpolateOptions { [key: string]: any // interpolation } interface TranslateOptions extends InterpolateOptions { scope?: Scope message?: string defaults?: Array<{ message: string } | { scope: Scope }> defaultValue?: string } function translate(scope: Scope, options?: TranslateOptions): string function t(scope: Scope, options?: TranslateOptions): string function localize( scope: 'currency' | 'number' | 'percentage', value: number, options?: InterpolateOptions ): string function localize( scope: Scope, value: string | number | Date, options?: InterpolateOptions ): string function l( scope: 'currency' | 'number' | 'percentage', value: number, options?: InterpolateOptions ): string function l( scope: Scope, value: string | number | Date, options?: InterpolateOptions ): string interface ToNumberOptions { precision?: number separator?: string delimiter?: string strip_insignificant_zeros?: boolean } function toNumber(num: number, options?: ToNumberOptions): string type ToPercentageOptions = ToNumberOptions function toPercentage(num: number, options?: ToPercentageOptions): string interface ToCurrencyOptions extends ToNumberOptions { format?: string unit?: string sign_first?: boolean } function toCurrency(num: number, options?: ToCurrencyOptions): string function toTime(scope: Scope, value: string | number | Date): string interface ToHumanSizeOptions extends ToNumberOptions { format?: string } function toHumanSize(num: number, options?: ToHumanSizeOptions): string function strftime(date: Date, format: string): string } declare module '@procore/core-i18n-js' { type VendorI18n = typeof I18n /** * @deprecated to get all locales available, * you can use TMS_SUPPORTED_LOCALE list or ALL_LOCALES list from [Globalization toolkit](https://github.com/procore/globalization-toolkit) * @deprecatedSince 10.29.0 */ export const locale = { deDE: 'de-DE', en: 'en', enCA: 'en-CA', frCA: 'fr-CA', frFR: 'fr-FR', es: 'es', esES: 'es-ES', AU: 'en-AU', enAE: 'en-AE', enGB: 'en-GB', enSG: 'en-SG', jaJP: 'ja-JP', th: 'th-TH', ptBR: 'pt-BR', is: 'is-IS', zhCN: 'zh-SG', pseudo: 'pseudo', plPL: 'pl-PL', nbNO: 'nb-NO', zhTW: 'zh-TW', itIT: 'it-IT', ptPT: 'pt-PT', } as const /** * @deprecated this type will no longer be supported from core-i18n-js, * to have a type safe Locale use TmsSupportedLocale or AllLocales from [Globalization toolkit](https://github.com/procore/globalization-toolkit) * @deprecatedSince 10.29.0 */ export type Locale = (typeof locale)[keyof typeof locale] interface I18njs extends VendorI18n { locale: Locale } interface I18njsConfig { I18n?: I18njs locale?: Locale translations?: Record } function createI18njs(config: I18njsConfig): I18njs }