piral-translate
Version:
Plugin for providing translated messages in Piral.
28 lines (27 loc) • 1.22 kB
TypeScript
import { LocalizationMessages, Localizable, NestedLocalizationMessages, TranslationFallback } from './types';
export declare class Localizer implements Localizable {
language: string;
languages: Array<string>;
private fallback;
messages: LocalizationMessages;
/**
* Creates a new instance of a localizer.
*/
constructor(messages: LocalizationMessages | NestedLocalizationMessages, language: string, languages: Array<string>, fallback?: TranslationFallback);
/**
* Localizes the given key via the global translations.
* @param key The key of the translation snippet.
* @param variables The optional variables to use.
*/
localizeGlobal<T extends object>(key: string, variables?: T): string;
/**
* Localizes the given key via the local translations.
* Uses the global translations as fallback mechanism.
* @param localMessages The local translations to prefer.
* @param key The key of the translation snippet.
* @param variables The optional variables to use.
*/
localizeLocal<T extends object>(localMessages: LocalizationMessages, key: string, variables?: T): string;
private localizeBase;
private translateMessage;
}