We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 786aeda commit ba7f83cCopy full SHA for ba7f83c
src/global/translations.ts
@@ -18,9 +18,21 @@ const allTranslations = {
18
sv: sv,
19
};
20
21
+const REGEX = /\{\s*(\w+)\s*\}/g;
22
+
23
export class Translations {
- public get(key, language = 'en') {
- return allTranslations[language][key];
24
+ public get(key: string, language = 'en', params?: object): string {
25
+ const translation = allTranslations[language][key];
26
+ if (!translation) {
27
+ return key;
28
+ }
29
30
+ return translation.replace(
31
+ REGEX,
32
+ (match: string, mergeCodeKey: string) => {
33
+ return params[mergeCodeKey] || match;
34
+ },
35
+ );
36
}
37
38
0 commit comments