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

Missing <context context-type="linenumber"></context> leads to cryptic error message #110

Open
floisloading opened this issue May 13, 2024 · 0 comments
Assignees
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@floisloading
Copy link

Describe the bug
After a Pull Request where the XLIFF File was formatted, I got a strange Error message when running ng extract-i18n:

An unhandled exception occurred: Cannot read properties of undefined (reading 'val')
See "/private/var/folders/kd/__0vzmb92fd1f2_k_kxvyrmc0000gn/T/ng-gwLO3C/angular-errors.log" for further details.

and in the angular-errors.log file:

[error] TypeError: Cannot read properties of undefined (reading 'val')
    at /Users/floisloading/Workspace/my-frontend/node_modules/ng-extract-i18n-merge/dist/src/model/translationFileSerialization.js:81:98
    at Array.map (<anonymous>)
    at /Users/floisloading/Workspace/my-frontend/node_modules/ng-extract-i18n-merge/dist/src/model/translationFileSerialization.js:79:18
    at Array.map (<anonymous>)
    at fromXlf1 (/Users/floisloading/Workspace/my-frontend/node_modules/ng-extract-i18n-merge/dist/src/model/translationFileSerialization.js:67:10)
    at fromXlf (/Users/floisloading/Workspace/my-frontend/node_modules/ng-extract-i18n-merge/dist/src/builder.js:78:129)
    at /Users/floisloading/Workspace/my-frontend/node_modules/ng-extract-i18n-merge/dist/src/builder.js:97:47
    at Generator.next (<anonymous>)
    at fulfilled (/Users/floisloading/Workspace/my-frontend/node_modules/ng-extract-i18n-merge/dist/src/builder.js:5:58)

After investigating I found out that both messages.xlf and messages.en.xlf were missing one <context context-type="linenumber"></context> inside one single <context-group>. It got accidentially removed while merging.

In messages.xlf, this works:

      <trans-unit id="8a43db3f950c8e283488f48553c494bbac00ab80" datatype="html">
        <source>Über das Programm</source>
        <note priority="1" from="description">Headline of main info on program detail page</note>
        <context-group purpose="location">
          <context context-type="sourcefile">src/app/program/program-main-info/program-main-info.component.html</context>
          <context context-type="linenumber">8</context>
        </context-group>
      </trans-unit>

while this doesn't:

      <trans-unit id="8a43db3f950c8e283488f48553c494bbac00ab80" datatype="html">
        <source>Über das Programm</source>
        <note priority="1" from="description">Headline of main info on program detail page</note>
        <context-group purpose="location">
          <context context-type="sourcefile">src/app/program/program-main-info/program-main-info.component.html</context>
        </context-group>
      </trans-unit>

Setup/Configuration

"extract-i18n": {
  "builder": "ng-extract-i18n-merge:ng-extract-i18n-merge",
  "options": {
    "buildTarget": "my-frontend:build",
    "format": "xlf",
    "outputPath": "src/i18n",
    "targetFiles": ["messages.en.xlf"],
    "includeContext": true,
    "trim": true,
    "newTranslationTargetsBlank": true
  }
},

Expected behavior

  • the missing context Tag should be extracted from the source code
  • the error message should point to the missing element

Screenshots
none

Version:

  • Angular: 17.2.1
  • OS: macOS 14.4.1 (23E224)
  • nodejs: 18.13.0
  • ng-extract-i18n-merge version: 2.11.2

Additional information:
Source language is de

@floisloading floisloading added the bug Something isn't working label May 13, 2024
@daniel-sc daniel-sc self-assigned this Sep 22, 2024
@daniel-sc daniel-sc added the good first issue Good for newcomers label Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants