diff --git a/ts/localization/I18nMethods.d.ts b/ts/localization/I18nMethods.d.ts new file mode 100644 index 000000000..69a7130aa --- /dev/null +++ b/ts/localization/I18nMethods.d.ts @@ -0,0 +1,28 @@ +import type { CrowdinLocale } from './constants'; +import type { + MergedLocalizerTokens, + GetMessageArgs, + LocalizerComponentProps, + SimpleLocalizerTokens, + ArgsFromToken, +} from './localeTools'; + +export type I18nMethods = { + /** @see {@link window.i18n.stripped} */ + stripped: (...[token, args]: GetMessageArgs) => string | T; + strippedWithObj: ( + opts: LocalizerComponentProps + ) => string | T; + /** @see {@link window.i18n.inEnglish} */ + inEnglish: (token: T) => string | T; + /** @see {@link window.i18n.formatMessageWithArgs */ + getRawMessage: ( + crowdinLocale: CrowdinLocale, + ...[token, args]: GetMessageArgs + ) => string | T; + /** @see {@link window.i18n.formatMessageWithArgs} */ + formatMessageWithArgs: ( + rawMessage: string, + args?: ArgsFromToken + ) => string | T; +}; diff --git a/ts/localization/localeTools.ts b/ts/localization/localeTools.ts index 326173b30..69722a5d8 100644 --- a/ts/localization/localeTools.ts +++ b/ts/localization/localeTools.ts @@ -1,6 +1,5 @@ -// eslint-disable-next-line no-restricted-imports -import type { I18nMethods } from '../types/localizer'; import { CrowdinLocale } from './constants'; +import type { I18nMethods } from './I18nMethods'; import { pluralsDictionary, simpleDictionary } from './locales'; type SimpleDictionary = typeof simpleDictionary; diff --git a/ts/types/localizer.d.ts b/ts/types/localizer.d.ts index b578d1db9..fdf790695 100644 --- a/ts/types/localizer.d.ts +++ b/ts/types/localizer.d.ts @@ -1,31 +1,5 @@ -import type { - ArgsFromToken, - MergedLocalizerTokens, - GetMessageArgs, - LocalizerComponentProps, - SimpleLocalizerTokens, -} from '../localization/localeTools'; -import { CrowdinLocale } from '../localization/constants'; - -export type I18nMethods = { - /** @see {@link window.i18n.stripped} */ - stripped: (...[token, args]: GetMessageArgs) => string | T; - strippedWithObj: ( - opts: LocalizerComponentProps - ) => string | T; - /** @see {@link window.i18n.inEnglish} */ - inEnglish: (token: T) => string | T; - /** @see {@link window.i18n.formatMessageWithArgs */ - getRawMessage: ( - crowdinLocale: CrowdinLocale, - ...[token, args]: GetMessageArgs - ) => string | T; - /** @see {@link window.i18n.formatMessageWithArgs} */ - formatMessageWithArgs: ( - rawMessage: string, - args?: ArgsFromToken - ) => string | T; -}; +import type { MergedLocalizerTokens, GetMessageArgs } from '../localization/localeTools'; +import type { I18nMethods } from './I18nMethods'; export type SetupI18nReturnType = I18nMethods & ((...[token, args]: GetMessageArgs) => string); diff --git a/ts/window.d.ts b/ts/window.d.ts index c384cf8e2..11c98e329 100644 --- a/ts/window.d.ts +++ b/ts/window.d.ts @@ -5,7 +5,8 @@ import { Store } from '@reduxjs/toolkit'; import { Persistor } from 'redux-persist/es/types'; import { PrimaryColorStateType, ThemeStateType } from './themes/constants/colors'; -import type { GetMessageArgs, I18nMethods } from './types/localizer'; +import type { GetMessageArgs } from './types/localizer'; +import type { I18nMethods } from './types/I18nMethods'; import type { MergedLocalizerTokens } from './localization/localeTools'; export interface LibTextsecure {