core icon indicating copy to clipboard operation
core copied to clipboard

fix(directive): translate by attribute (not binding) with translation key as value

Open hosuaby opened this issue 3 years ago • 0 comments

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.

hosuaby avatar Nov 19 '20 14:11 hosuaby