Core: Double language change will not translate with directive on untrimmed value

Created on 28 Jun 2019  路  3Comments  路  Source: ngx-translate/core

Current behavior

Having an untrimmed text value will lead to bad behavior when changing the language twice
'untrimmed':
<button translate>text </button>

Expected behavior

  • translation will not work once
  • or translation will work as often as you change language

How do you think that we should fix this?

As i took a look at the code it seems like a caching / comparing problem.
So fix the code.

Minimal reproduction of the problem with instructions

Environment


ngx-translate version: ^11.0.1
Angular version: 8.0.1


Browser:
- [X] Chrome (desktop) version 75.0.3770.100 (Offizieller Build) (64-Bit)
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [X] Firefox version 66.0.5 (64-Bit)
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [X] IE version 11.0.9600.19377
- [ ] Edge version XX

For Tooling issues:
- Node version: XX  v10.15.3
- Platform:  Windows

Others:

minimal code:

minimal.ts.txt

maybe it depends on https://github.com/ngx-translate/core/issues/808 but hopefully more reproducable

All 3 comments

Where did you find this way of using ngx-translate/core?
Please take a look https://github.com/ngx-translate/core#4-use-the-service-the-pipe-or-the-directive

You need to 'tell' _directive_ or _pipe_ what translation value it needs to search for:

<button translate="click-me"></button>
<button translate="click-me">{{'click-me' | translate}}</button>

using your link

Please take a look https://github.com/ngx-translate/core#4-use-the-service-the-pipe-or-the-directive

Or even simpler using the content of your element as a key: <div translate [translateParams]="{value: 'world'}">HELLO</div>

and having empty translateParams.

And I know, that there are possibilities to get the desired translation. Just wanted to be fair and report the strange behavior.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bjornharvold picture bjornharvold  路  3Comments

louisdoe picture louisdoe  路  3Comments

crebuh picture crebuh  路  3Comments

rbaumi picture rbaumi  路  4Comments

chris31389 picture chris31389  路  3Comments