Wiki source code of Front-end localization API

Last modified by Manuel Leduc on 2026/03/26 17:40

Hide last authors
Manuel Leduc 1.1 1 == Query ==
2
3 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.
4
5 {{code language='typescript'}}
6 Query: string[] | { keys: string[]; prefix?: string }
7 {{/code}}
8
9 == Resolver ==
10
11 The results of a full translation resolution. Including missed translations.
12
13 {{code language='typescript'}}
14 type Resolver = {
15 resolve(query: Query): Promise<TranslationsWithMissed>;
16 }
17 {{/code}}
18
19 == Translations ==
20
21 A resolved query, in the form of a map with the translation keys and their associated translation values.
22
23 {{code language='typescript'}}
24 Translations: { [key: string]: string }
25 {{/code}}
26
27 == TranslationsWithMissed ==
28
29 An object holding the translations but also the requested keys that failed to be resolved.
30
31 {{code language='typescript'}}
32 type TranslationsWithMissed = {
33 missed?: string[];
34 translations: Translations;
35 }
36 {{/code}}
37
38 == Translator ==
39
40 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.
41
42 {{code language='typescript'}}
43 type Translator = {
44 resolve(query: Query): Promise<Translations>;
45 }
46 {{/code}}

Get Connected