import { Converter, GroupedTranslations, Keywords, Translatable, TranslationsList } from "./types.mjs"; //#region ../localization/src/translator.d.ts /** * Get current locale code */ declare function getCurrentLocaleCode(): string; /** * Get fallback locale code */ declare function getFallbackLocaleCode(): string; /** * Set current converter */ declare function setConverter(converter: Converter): void; /** * Get the locale code used in translation, this allows to get the locale code on the fly */ declare function getTranslationLocaleCode(): string; /** * Set current locale code */ declare function setCurrentLocaleCode(localeCode: string): void; /** * Add keywords */ declare function extend(localeCode: string, keywords: Keywords): void; /** * Create a grouped translations based on keyword, each keyword contains list of locale codes and beside it its corresponding translation * * @example * { * home: { * en: "Home", * ar: "الرئيسية" * } * } * * Also it could have nested grouped translations * * @example * { * general: { * home: { * en: "Home", * ar: "الرئيسية" * } * } */ declare function groupedTranslations(groupKey?: string | GroupedTranslations, groupedTranslations?: GroupedTranslations): void; /** * Override the entire translations list */ declare function setTranslationsList(translations: TranslationsList): void; /** * Get the entire translations list */ declare function getTranslationsList(): TranslationsList; /** * Get the keywords list of the given locale code */ declare function getKeywordsListOf(localeCode: string): Keywords | null; /** * Set fallback locale code, if the keyword does not exist on current locale code, * then check it in the faLLBACK locale code instead */ declare function setFallbackLocaleCode(fallbackLocale: string): void; /** * Translate the given keyword in current locale code */ declare function trans(keyword: Translatable, placeholders?: any, converter?: Converter): any; /** * Translate using the default converter */ declare function plainTrans(keyword: string, placeholders?: any): any; /** * Translate the given keyword for the given locale code * Please note this method accepts dot notation syntax */ declare function transFrom(localeCode: string, keyword: Translatable, placeholders?: any, converter?: Converter): any; type WithPlaceholder = { p: (keyword: keyof T, placeholders?: any) => string; plain: (keyword: keyof T, placeholders?: any) => string; }; /** * Get a translation object with automatic translation using object syntax * Please note this does not support nested objects, only keywords and their translations * i.e * const translations = transObject({ * name: { * en: 'name', * ar: 'الاسم' * } * }); * * Usage: translations.name // returns the name in current locale code * If the keyword does not exist on current locale code, then it will check it in the fallback locale code * * If keyword is "p", then it will return a function that accepts keyword and its placeholders * If keyword is "plain", then the converter used in translation will be the plain converter */ declare function transObject(translations: T): WithPlaceholder & { [key in keyof T]: string }; //#endregion export { WithPlaceholder, extend, getCurrentLocaleCode, getFallbackLocaleCode, getKeywordsListOf, getTranslationLocaleCode, getTranslationsList, groupedTranslations, plainTrans, setConverter, setCurrentLocaleCode, setFallbackLocaleCode, setTranslationsList, trans, transFrom, transObject }; //# sourceMappingURL=translator.d.mts.map