UNPKG

adnbn

Version:

Addon Bone - Cross-browser web extension framework with shared code base

48 lines (45 loc) 2.72 kB
import { LocaleNonPluralKeys, LocaleSubstitutionsFor, LocalePluralKeys } from '../types/locale.js'; import { LocaleNativeStructure } from './providers/NativeLocale.js'; import './providers/AbstractLocale.js'; /** * Translates a given locale key into the corresponding localized string. * * @template K - A type representing the non-plural keys of the locale structure. * @param {K} key - The locale key to be translated. * @param {LocaleSubstitutionsFor<LocaleNativeStructure, K>} [substitutions] - Optional substitutions to be applied * within the localized string. These are typically placeholders replaced with dynamic values. * @returns {string} - The translated string for the given key, with substitutions applied if provided. */ declare const _: <K extends LocaleNonPluralKeys<LocaleNativeStructure>>(key: K, substitutions?: LocaleSubstitutionsFor<LocaleNativeStructure, K>) => string; /** * Translates a given locale key into the corresponding localized string * based on a specific count for pluralization. * * @template K - A type representing the non-plural keys of the locale structure. * @param {K} key - The locale key to be translated. * @param {number} count - The count used to determine the pluralization form. * @param {LocaleSubstitutionsFor<LocaleNativeStructure, K>} [substitutions] - Optional substitutions to be applied * within the localized string. These are typically placeholders replaced with dynamic values. * @returns {string} - The translated string for the given key, adjusted for pluralization and with substitutions applied if provided. */ declare const _c: <K extends LocalePluralKeys<LocaleNativeStructure>>(key: K, count: number, substitutions?: LocaleSubstitutionsFor<LocaleNativeStructure, K>) => string; /** * Converts a locale key into a standardized format and logs a warning if the key is not found * in the current language's locale keys. * * @param {Extract<keyof LocaleNativeStructure, string>} key - The locale key to be converted. * This key must be a string and exist within the `LocaleNativeStructure`. * @returns {string} - The converted locale message key. */ declare const __: (key: keyof LocaleNativeStructure & string) => string; /** * Attempts to extract a locale key from the provided string and translates it * into the corresponding localized string. If no locale key can be extracted, * the original string is returned. * * @param {string} input - The input string from which a locale key is to be extracted. * @returns {string} - The translated string if a locale key is successfully extracted, * or the original string if no locale key is found. */ declare const __t: (input: string) => string; export { _, __, __t, _c };