Is there a way to determine if a string has been translated using AngularJS and AngularTranslate?
I'm looking for a method to display a value only if it has been properly translated. If no translation is available, AngularTranslate will show the untranslated string.
Initially, I tried the following approach:
<div ng-if="question.text | translate != question.text">{{ question.text | translate }}</div>
However, this method did not work as expected because the comparison occurs before the translate filter is applied. (Or at least that's what I think is happening).
As a workaround, I implemented the following solution:
.filter('isTranslated', function(){
return function(translatedVal, originalVal){
return (translatedVal === originalVal) ? false : true;
}
})
<div ng-if="question.text | translate | isTranslated:question.text">{{ question.text | translate }}</div>
This solution works perfectly fine, but I am curious if there is a more efficient way of achieving the same result?