UNPKG

@stihl-design-system/components

Version:

Welcome to the STIHL Design System react component library.

28 lines (27 loc) 1.6 kB
/** * Language type for all translatable DS components. * Use `'de'` or `'en'` for preconfigured translations, or any * [BCP 47 language tag](https://www.rfc-editor.org/info/bcp47) * (e.g. `'fr'`, `'pl'`, `'en-GB'`) when providing a custom `translations` object. */ export type DSLanguage = 'de' | 'en' | (string & {}); /** * Translates a given key using ICU MessageFormat for proper pluralization and interpolation. * Supports named parameters (e.g. `{count}`) and ICU plural syntax * (e.g. `{count, plural, one {# item} other {# items}}`). * * @param key - The key identifying the text to be translated. * @param translations - Object containing translation mappings. * @param locale - The locale string used for CLDR plural rule resolution (e.g. 'en', 'de', 'pl'). * @param values - Optional record of named values to interpolate into the message. * @returns The translated string with all placeholders resolved. */ export declare const translate: <T extends Record<string, string>>(key: keyof T, translations: T, locale: string, values?: Record<string, string | number>) => string; /** * Higher-order function to bind translations and locale, returning a simple `t(key, values?)` helper. * * @param translations - Object containing translation mappings. * @param locale - The locale string used for CLDR plural rule resolution. * @returns A translation function `t(key, values?)`. */ export declare const translateWithTranslations: <T extends Record<string, string>>(translations: T, locale: string) => (key: keyof T, values?: Record<string, string | number>) => string;