refactor: utilize null coalescing

This commit is contained in:
Rainer Killinger
2020-10-30 16:34:28 +01:00
parent 15ae5e0873
commit 4865f911d1

View File

@@ -224,9 +224,7 @@ export class SCThingTranslator {
*/
public translatedPropertyNames<T extends SCThing>(type: SCThingType,
language?: keyof SCTranslations<T>): T | undefined {
const targetLanguage = (typeof language !== 'undefined') ? language : this.language;
return this.getAllMetaFieldTranslations(type, targetLanguage) as T;
return this.getAllMetaFieldTranslations(type, language ?? this.language) as T;
}
/**
@@ -246,7 +244,7 @@ export class SCThingTranslator {
language?: keyof SCTranslations<T>): string | undefined {
const fieldTranslation = this.getMetaClassInstance(type).fieldValueTranslations[language ?? this.language]?.[field];
return fieldTranslation?.[key ?? ''] ?? fieldTranslation ?? key;
return fieldTranslation?.[key ?? ''] ?? key ?? fieldTranslation;
}
/**