-
-
Notifications
You must be signed in to change notification settings - Fork 592
Labels
Description
Current behavior
There is no way to be certain about the existence of a translation for a specific key. The best thing I can do is checking if the translation is the same as the given key:
if (this.translate.instant(myKey) === myKey) { ... }
However, besides not being pretty, this cannot detect the case when the translation really is the same as the key.
Expected behavior
It would be nice to have a safe and concise test for the presence of a translation.
How do you think that we should implement this?
if(this.translate.hasTranslation(key)) { ... }
Nice bonus: Give it an optional argument for testing another language instead of the current:
hasTranslation(translationKey: string, language?: string): boolean
sgrillon14, danchr, gustavshf, etokareva, akhilsoman and 29 more