modals fully translated

This commit is contained in:
MathieuG-P
2022-07-15 15:12:05 +02:00
parent c61e3227ba
commit 599c36e8d7
10 changed files with 237 additions and 37 deletions
+8 -6
View File
@@ -44,12 +44,14 @@ export class I18nService {
this.configService.set("language" as DefaultConfigKey, this.getSupportedLanguages().includes(lang) ? lang : this.LANG_FALLBACK);
}
public translate(translationKey: string): string{
const cachedTranlation = this.cache.get(translationKey);
if(!!cachedTranlation){ return cachedTranlation; }
const tranlated = getProperty(this.dictionary, translationKey);
tranlated && this.cache.set(translationKey, tranlated);
return tranlated || translationKey;
public translate(translationKey: string, args?: Record<string, string>): string{
let translated = this.cache.get(translationKey);
if(!translated){
translated = getProperty(this.dictionary, translationKey);
translated ? this.cache.set(translated, translationKey) : translated = translationKey;
}
args && Object.keys(args).forEach(key => translated = translated.replaceAll(`{${key}}`, args[key]));
return translated;
}