daniel-sc / ng-extract-i18n-merge

Extract and merge i18n xliff translation files for angular projects.
MIT License
175 stars 18 forks source link

Whitespaces not trimmed properly? #43

Closed Hafnernuss closed 2 years ago

Hafnernuss commented 2 years ago

Describe the bug I am not sure if it's a bug as I am not sure I fully know if this is intended behaviour or not. I get a lot of warnings like this: image

Where some of the lines look like that:

<button class="col-4 btn w-100 btn-primary block" type="submit" (click)="onLogin()" i18n="Login|Auth@@Login">
    Login
</button>

This causes the translator to pick the string up as " Login " rather than "Login". Funny enough, the translation units seem to look "as expected": <source>Login</source>

Setup/Configuration

"extract-i18n": {
          "builder": "ng-extract-i18n-merge:ng-extract-i18n-merge",
          "options": {
            "browserTarget": "sportsense-tms:build",
            "format": "xlf",
            "collapseWhitespace": true,
            "trim": true,
            "includeContext": true,
            "outputPath": "src/locale",
            "targetFiles": [
              "messages.en.xlf",
              "messages.de.xlf"
            ]
          }
        }

and some translations like:

  <button class="col-4 btn w-100 btn-primary block" type="submit" (click)="onLogin()" i18n="Login|Auth@@Login">
    Login
  </button>

and

<button class="btn btn-primary" (click)="onLogin()" id="login" i18n="Login|ResetPassword@@Login">Login</button>

Expected behavior No warnings

Version (please complete the following information):

Additional context angular issue

daniel-sc commented 2 years ago

@Hafnernuss This is from the angular i18n extraction. See https://stackoverflow.com/q/70900706/2544163

Hafnernuss commented 2 years ago

so this means there is nothing I can do? I have to break sometimes because of line length limits...

daniel-sc commented 2 years ago

I'd recommend too use line breaks before and after all texts where this problem occurs. (This is how I do it in my project.)

Besides this, there is little you can do, I'm afraid.

Hafnernuss commented 2 years ago

Ok thanks, I will simply break everywhere. Looks cleaner anyway ;) Thank you!