UNPKG

@bemedev/i18n

Version:

Internationalization library for Bemedev projects, providing utilities for managing translations and locale-specific content.

29 lines 1.61 kB
import { defineTranslation } from './helpers'; import type { _Translations, KeyU, LanguageMessages, Paths, Translate_F } from './types'; declare class I18n<const R extends LanguageMessages, const Keys extends string[], Tr extends Partial<_Translations<R>> = Partial<_Translations<R>>> { #private; private _config; get config(): R; get translations(): Record<Keys[number], Tr>; get keys(): Keys[number][]; /** * @deprecated Used only for typing (TypeScript). Do not use this property at runtime. */ get __key(): Keys[number]; /** * @deprecated Used only for typing (TypeScript). Do not use this property at runtime. */ get __translation(): Tr; constructor(_config: R, ...initials: Keys); provideTranslation: <const K extends string, V extends Tr>(key: K, func: ((define: typeof defineTranslation) => V) | V) => I18n<R, [...Keys, K]>; translateWithLocale: (locale: Keys[number], values: Paths<R>) => string; translate: Translate_F<R, Keys[number]>; } export { type I18n }; export type ConfigFrom<T extends KeyU<'config'>> = T['config']; export type KeysFrom<T extends KeyU<'keys'>> = T['keys']; export type KeyFrom<T extends KeyU<'__key'>> = T['__key']; export type TranslationsFrom<T extends KeyU<'translations'>> = T['translations']; export type TranslationFrom<T extends KeyU<'__translation'>> = T['__translation']; export declare const create: <const K extends [string, ...string[]], const R extends LanguageMessages>(func: ((define: typeof defineTranslation) => R) | R, ...fallbacks: K) => I18n<R, K>; //# sourceMappingURL=class.d.ts.map