core icon indicating copy to clipboard operation
core copied to clipboard

spaces at the start/end of translation causes problems when switching languages

Open robstoll opened this issue 5 years ago • 0 comments

Current behavior

Switching languages does not work correctly when a translation has spaces at the end of the translation

Expected behavior

Works in all cases

How do you think that we should fix this?

I guess easiest is to trim the text before translation

Minimal reproduction of the problem with instructions

<p translate>
  Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore 
  et dolore magna   aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum.
</p>

the problem are the leading and ending spaces. For whatever reason the translate does not work this way, in certain scenarios:

  • if I enter directly the url to the site (if I navigate away and come back then it works)
  • if I choose the main language in which the key is null in the .json file (in my case DE) it switches to DE but I cannot switch back to EN, the translate somehow does not kick in.

note that it does not happen if there is no space at the beginning and end of the tag, then every scenario above works as it should. I.e. if it is as follows:

<p translate>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore 
  et dolore magna   aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum.</p>

Environment


ngx-translate version: 12.0.0
Angular version: 9.0.1

Browser:
- [ ] Chrome (desktop) version 
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [x] Firefox version 80.0.1 (64-bit)
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
 
For Tooling issues:
- Node version: v13.14.0
- Platform:  linux

robstoll avatar Sep 29 '20 18:09 robstoll