core
core copied to clipboard
Translate objects recursively when key points to object in translations
trafficstars
fix for #946
Motivation:
I want to be able to use the translate pipe in combination with the *ngFor keyword in my angular components
With this Pull Request the following now works...
translations.json
{
OBJECT: {
TEST: 'this is a test {{key}}',
ANOTHER_TEST: 'this is another test {{key}}'
}
}
any view
<ul>
<li *ngFor="let translation of 'OBJECT' | translate: { key: 'value' } | keyvalue">{ translation.value }</li>
</ul>
result
<ul>
<li>this is a test value</li>
<li>this is another test value</li>
</ul>
previously the interpolation would fail, resulting in
<ul>
<li>this is a test {{key}}</li>
<li>this is another test {{key}}</li>
</ul>
Integrated in upcoming ngx-transalte 16 https://github.com/CodeAndWeb/ngx-translate/commit/f304f9ba2098678788145f834bc34d271ce3e918
In your fork v16, please do not make people confused
Fixed in @ngx-translate/core@16