Front-end localization API
Reference
Query
A query expresses the set of translations to be resolved. It can be either an array of full translation keys, or an array of translation key suffixes plus a separate shared prefix.
Query: string[] | { keys: string[]; prefix?: string }Resolver
The results of a full translation resolution. Including missed translations.
type Resolver = {
resolve(query: Query): Promise<TranslationsWithMissed>;
}Translations
A resolved query, in the form of a map with the translation keys and their associated translation values.
Translations: { [key: string]: string }TranslationsWithMissed
An object holding the translations but also the requested keys that failed to be resolved.
type TranslationsWithMissed = {
missed?: string[];
translations: Translations;
}Translator
A translator, take a query and returns translations. Translators are expected to be chained, the next translations received a query where keys resolved by the previous translator are removed. A translator only return the translations it can find, leaving the next translator of the chain resolve the unresolved ones.
type Translator = {
resolve(query: Query): Promise<Translations>;
}