daniel-sc / ng-extract-i18n-merge

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

Cannot read properties of undefined (reading 'childNamed') #90

Closed worthy7 closed 7 months ago

worthy7 commented 7 months ago

Describe the bug Simply running the script doesn't work. When the target file does not already exists, it creates it fine with no error. When it already exists, it throws this error.

Setup/Configuration Provide relevant (parts) of files like angular.json, package.json, messages.xlf etc.

Angular.json

 "extract-i18n": {
          "builder": "ng-extract-i18n-merge:ng-extract-i18n-merge",
          "options": {
            "browserTarget": "home:build",
            "format": "xlf2",
            "outputPath": "projects/home/src/i18n",
            "targetFiles": ["messages.ja.xlf"]
          }
        },

samples japanese messages.js.xlf

<?xml version="1.0" encoding="UTF-8"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
  <file source-language="en-US" datatype="plaintext" original="ng2.template">
    <body>
      <trans-unit id="cfba7b438a8d15f97984d3fd83c4a9d4516bb52c" datatype="html">
        <source> Super Simple Scheduling </source>
        <target> 簡単な予約! </target>
        <context-group purpose="location">
          <context context-type="sourcefile">
            projects/home/src/app/landing-page/home-page/home-page.component.html</context>
          <context context-type="linenumber">24,26</context>
        </context-group>
      </trans-unit>
    </body>
  </file>
</xliff>

Expected behavior No error, merge correctly.

Screenshots If applicable, add screenshots to help explain your problem. image

Version (please complete the following information):

worthy7 commented 7 months ago

Ah, this happens when the existing format xlf, xlif, xliff, xlf2, xliff2 is different from the designated format in config