core
core copied to clipboard
fix(directive): translate by attribute (not binding) with translation key as value
Fix for angular 9 & 10
This PR fixes the behaiviour of TranslateDirective
when it is used as a simple attribute translate
(not attribute binding [translate]
) with value and translated element already contains some text. Example:
<div #attributeWithValue translate="TEST">Should be changed</div>
<div #attributeWithValueAndParams translate="TEST" [translateParams]="{value: 'great'}">Should be changed</div>
Currently (without this fix) this code will result in text translated twice. If value for 'TEST'
in english is "This is a test", after directive is executed, value of #attributeWithValue will be "This is a testThis is a test".
There was no such problem while using ng-translate with Angular 8. But since Angular 9 it appeared.
This PR also contains some refactorings.