Skip to content
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

Space trimming #28

Closed
yehorlitsov opened this issue May 9, 2022 · 6 comments · Fixed by #29
Closed

Space trimming #28

yehorlitsov opened this issue May 9, 2022 · 6 comments · Fixed by #29
Assignees
Labels
bug Something isn't working

Comments

@yehorlitsov
Copy link

yehorlitsov commented May 9, 2022

Looks like extract-i18n-merge command trims spaces, but extract-i18n don't. I have cases when i don't need to trim them.
Screenshot 2022-05-09 at 21 14 51

<span
  class="link-ghost"
  i18n="Phone Verification"
> Change</span>

I have a space before Change. But as a result i have:

<trans-unit id="ba3ab8408e0985aaa20a3c83f77a8bc336a96ae4" datatype="html">
  <source>Change</source>
  <context-group purpose="location">
    ...
  </context-group>
  <note priority="1" from="description">Phone Verification</note>
</trans-unit>

May be there is any extra config except collapseWhitespace?
"ng-extract-i18n-merge": "^1.4.0",

@daniel-sc
Copy link
Owner

Hi @yehorlitsov
Thanks for your feedback. This option is not yet available. Before adding it I'd like to understand why it is needed. In my experience these white spaces get trimmed in the ng build - so it makes no difference for the final output. But please let me know why you'd rather not have it trimmed!
Best
Daniel

@yehorlitsov
Copy link
Author

Hi!
Yes, sorry, might be i provided incomplete information and forgot to greeting :)
npm run extract-i18n build everything without trimming, like i mentioned in first message, in such cases like this

<div>
  <ng-container>Some string </ng-container>
  <span>{{someValue}}</span>
  <span> some final.</span>
</div>

the result will be Some string VALUE some final.
But using nom run extract-i18n-merge the result after build will be Some stringVALUEsome final.
It's an issue for me, so i have to do something like this in each case:

<div>
  <ng-container>Some string</ng-container>
  <span>&nbsp;</span>
  <span>{{someValue}}</span>
  <span>&nbsp;</span>
  <span> some final.</span>
</div>

Before i used npm run extract-i18n and @ngx-i18nsupport/tooling with its xlf-merge, but after update to Angular 13 had an issue with lib. So that's why i switched to yours, and everything works great except this one small thing.
Thank you!
Best
Yehor

@daniel-sc
Copy link
Owner

@yehorlitsov you are right (angular compiler removes whitespaces between nodes, but not within..)

@daniel-sc daniel-sc self-assigned this May 16, 2022
@daniel-sc daniel-sc added the bug Something isn't working label May 16, 2022
daniel-sc added a commit that referenced this issue May 16, 2022
fixes #28

BREAKING CHANGE: Leading/Trailing whitespaces can lead to visible changes.
If in doubt, check and remove whitespaces in your template files.
@daniel-sc
Copy link
Owner

@yehorlitsov would you mind checking out the pre-release 2.0.0-0 and report back if it works as intended from your side?

@yehorlitsov
Copy link
Author

@daniel-sc thank you, this pre-release 2.0.0-0 solved the problem for me. Sorry for long reply

@daniel-sc daniel-sc linked a pull request May 24, 2022 that will close this issue
daniel-sc added a commit that referenced this issue May 24, 2022
@Hafnernuss
Copy link

If this is completly resolved, maybe consider removing

Leading/trailing whitespaces are normalized (i.e. collapsed to one space) but not completely trimmed (#28).
from the docs? 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants