daniel-sc / ng-extract-i18n-merge

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

Invalid attribute name error on merge and normalizing step #121

Closed sporatrx closed 4 days ago

sporatrx commented 1 week ago

Bug Description I am experiencing a problem executing extract-i18n on an existing project of mine since some update as it did work before. Unfortunately I do not know when this error did start popping up and to which update it thus might be related.

When executing extract-i18n on my project it successfully extracts the strings into my messages.xlf file but fails at the next step when trying to merge and normalize the first localized messages.xlf file (In my case it is named messages.de-DE.xlf.) with the error:

An unhandled exception occurred: Invalid attribute name
Line: 0
Column: 68
Char: "
See "/private/var/folders/bt/l2td87q16sj_vlx9qbt9qgbc0000gp/T/ng-2YQAOp/angular-errors.log" for further details.

image

This seems to be some kind of sax.js error as far as I understand. I checked both the messages.xlf and messages.de-DE.xlf files if they are valid XML. Both are fine.

Can you point me into the right direction what might cause this error? I can also provide you the files in question if needed. I first have to check back with my employer though if this is okay.

Expected behavior All xlf files should be merged and updated with newly extracted strings from the messages.xlf file.

Version

daniel-sc commented 1 week ago

@sporatrx I'd suspect a malformed translation file. Would it be possible to share your configuration (angular.json) and your translation file either here or privately? (daniel-schreiber@gmx.de)

sporatrx commented 5 days ago

@daniel-sc Sorry for the wait! I had to clarify if it is okay to share these files. I sent you an email with the needed files to your address.

mjschranz commented 5 days ago

Hi @daniel-sc and @sporatrx

I've been running into the same problem for projects. When you mention what you want shared from angular.json, do you mean just the following?


        "extract-i18n": {

          "builder": "ng-extract-i18n-merge:ng-extract-i18n-merge",

          "options": {

            "buildTarget": "pdf-template-mpr:build",

            "format": "xlf",

            "outputPath": "src/locale",

            "targetFiles": ["messages.fr.xlf", "messages.en.xlf"]

          }

        },

Sadly I can't attach XLF files here directly.

daniel-sc commented 4 days ago

@sporatrx @mjschranz can you please check if v2.13.1 resolves it for you? (Note: the issue was a quote (" / ") in one of the ids)

sporatrx commented 4 days ago

I can verify that extracting strings now works again for me. image Thank you very much for the quick help.

mjschranz commented 4 days ago

I can also verify this fixed the issue I saw.

Thanks!

On Wed, Nov 27, 2024, 8:50 a.m. sporatrx @.***> wrote:

I can verify that extracting strings now works again for me. image.png (view on web) https://github.com/user-attachments/assets/40789c49-d90c-4929-96b4-568d9a5ba56c Thank you very much for the quick help.

— Reply to this email directly, view it on GitHub https://github.com/daniel-sc/ng-extract-i18n-merge/issues/121#issuecomment-2503928175, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAG3TZIVGGLMXKGY2YXIPVD2CXEZBAVCNFSM6AAAAABSHIK25CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKMBTHEZDQMJXGU . You are receiving this because you were mentioned.Message ID: @.***>

mjschranz commented 4 days ago

@daniel-sc Related to this error, I'm seeing something else similar after using this newer 2.13.1 patch but in another project that also uses XLF files. The 2.13.1 patch did still work for one project.

image001

Any thoughts? What info might you need>

daniel-sc commented 4 days ago

@mjschranz Please create a new bug for this and share the relevant xlf files and angular.json (preferably in the bug - alternatively to daniel-schreiber@gmx.de)