daniel-sc / ng-extract-i18n-merge

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

extract-18n skip some modules #64

Closed JleHi closed 1 year ago

JleHi commented 1 year ago

Describe the bug I have an angular app developped with lazy-loaded modules architecture. I have a CoreModule, a SharedModule and some features modules grouped in the features folder. When I run ng extract-i18n it extract every string marked for translation inside the features folder but none of those inside CoreModule and SharedModule.

Setup/Configuration The extract-i18n entry in my angular.json file is like below :

"extract-i18n": {
          "builder": "ng-extract-i18n-merge:ng-extract-i18n-merge",
          "options": {
            "browserTarget": "melofeel-front:build",
            "format": "xlf2",
            "outputPath": "src/locale",
            "targetFiles": [
              "messages.fr.xlf"
            ],
            "sort": "idAsc"
          }
        },

Expected behavior I'd like to have all the marked string to appear in my messages.fr.xlf file.

Version (please complete the following information):

daniel-sc commented 1 year ago

Hi @JleHi Thanks for reporting this!

Would you be able to share a (minimal) reproduction? Preferably a git repo I could checkout and run npm install with a subsequent ng extract-i18n on to reproduce it.

JleHi commented 1 year ago

Hi @daniel-sc ,

Thanks for your answer. I've created a git repo on Github as you asked. I hope it is accessible, it's my first one : https://github.com/JleHi/repro-extract-i18n-missing-translations/

I can't post the project as it is so I made a short version of it for your tests. It has a slightly different comportment than the other: this one take the translations from CoreModule in account. But like the other the SharedModule seems to be ignored.

I've done this one in a hurry before leaving, let me know if something is wrong. Thanks again.

daniel-sc commented 1 year ago

@JleHi thanks for providing a reproduction! It seems that the component in your shared module was not at all used in your application - this directly implies that the translations from this component cannot be extracted by angular (and cannot be managed by this plugin).

To prove this, I used the shared component in one of your feature components and then the i18n text is contained in the messages.(fr.)xlf - see https://github.com/JleHi/repro-extract-i18n-missing-translations/pull/1

Please reopen, if there is some other problem I overlooked!