UNPKG

piral-translate

Version:

Plugin for providing translated messages in Piral.

34 lines (33 loc) 1.14 kB
import type { PiralPlugin } from 'piral-core'; import type { PiletLocaleApi, Localizable, AnyLocalizationMessages, TranslationFallback } from './types'; export interface RetrieveCurrentLanguage { /** * A function to identify the current language. */ (languages: Array<string>, defaultLanguage: string, fallbackLanguage?: string): string; } export interface LocaleConfig { /** * Sets the default (global) localization messages. * @default {} */ messages?: AnyLocalizationMessages; /** * Sets the default language to use. */ language?: string | RetrieveCurrentLanguage; /** * Sets the optional fallback to use. */ fallback?: TranslationFallback; } /** * Sets up a new localizer by using the given config. * @param config The configuration for the new localizer. */ export declare function setupLocalizer(config?: LocaleConfig): Localizable; /** * Creates new Pilet API extensions for localization. * @param localizer The specific localizer to be used, if any. */ export declare function createLocaleApi(localizer?: Localizable): PiralPlugin<PiletLocaleApi>;