-
-
Notifications
You must be signed in to change notification settings - Fork 578
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When adding class to a div, translation gets crazy #1010
Comments
By accident, I found out a simpler version to reproduce the problem: <div class="value" translate>Sex.{{ viewModel?.sex }}</div>
<div class="property" translate>
Overview.Details.InfusionParameter.Sex
</div>
<div class="value" translate>Sex.{{ viewModel?.sex }}</div>
<div class="property" translate>Overview.Details.InfusionParameter.Sex</div> I had "Format on Save" activated and therefore VSCode inserted a LineBreak and some Spaces (see first version). This yields to the same problem with the weird [object Object stuff] |
I just added a newer and shorter version with less dependencies on stackblitz: https://stackblitz.com/edit/ngxtranslatebug?file=src/app/app.component.ts |
I just made another interesting observation while debugging ngx-translate-core.js. I observed that at some stage during the execution, the currentValue of the node, was set to my Sex-enum, which looks strange to me. So I tried something else. {
"Sex":{
"Female": "Female",
"Male": "Male",
"Inter": "Inter",
"Unknown": "-"
},
"Overview":{
"Sex": "Sex"
}
} So the the keys are: When I change my translation files to something like {
"SexEnum":{
"Female": "Female",
"Male": "Male",
"Inter": "Inter",
"Unknown": "-"
},
"Overview":{
"Sex": "Sex"
}
} my problem is gone. So obviously there is a problem, when tail of a key (Overview. So my question is: Is this a known limitation of this library, or a bug? |
I close my ticket, because I think the basic error that causes this behavior, is already described in #998 |
Current behavior
I created a repository to reproduce a bug, that occurred in my production code. You can see some of the errors in the screenshot below:
At the left you can see, that I set the currently language to 'de'. But not all languages are translated correctly, some of the translations (Age, Height, Weight) are in English (default language). Furthermore an existing translation is displayed as [object Object], instead of the expected translation 'Geschlecht' (sex in German).
This strange behavior appeared, after I added some class attribute to the properties and values (see commit in branch AddingClassYieldsError). The moment I remove the class (the commit before), the error is gone:The problem is actually caused by an editor option "Format on save" that add extras linebreaks and spaces. But I don't think this should be a problem.
Expected behavior
I expect that translations and styles can be used independently from each other. I want to use line-breaks and spaces ahead and after my translation key.
How do you think that we should fix this?
No idea.Translation keys should be trimmed, before they are used to look up a translation.Minimal reproduction of the problem with instructions
See my repository:
https://github.com/BADF00D/NgxTranslateBug
Or a shorter version: https://stackblitz.com/edit/ngxtranslatebug?file=src/app/app.component.ts
Environment
I was not yet able to reproduce the problem in i less expensive environment. The problem might be connected with primeng. the ui framework in use.It has nothing to do with primeng, see my stackblitz example: https://stackblitz.com/edit/ngxtranslatebug?file=src/app/app.component.tsThe text was updated successfully, but these errors were encountered: