Angular 17 library : add @angular/localize

356 Views Asked by At

I'm creating a new Angular 17 application. Some others will be created afterwards. So I want to create a library with main layout to be able to share it between all my applications.

As the application are localized through @angular/localize, I would like to keep the same way for the lib. But I have some troubles.

When I try to extract the i18n translations, this error occurs

    An unhandled exception occurred: The "paths[1]" argument must be of type string. Received undefined
See "C:\Users\xxxxxxx\AppData\Local\Temp\ng-0PQCGV\angular-errors.log" for further details.

And nothing in the mentionned log.

I have seen a workaround here (with localize-extract), but the generated file is empty. And no question about Angular > 11.

Another try was to generate the translations files and look for the translation of the library. Failed too.

All the questions found here wrote about Angular <= 11. I hope Angular 17 supports now the localization of librairies and I just miss something.

I created a Github repo to reproduce easily my case : my repo

1

There are 1 best solutions below

0
yuri.dev On

When you utilize the Angular CLI to generate a translation file for the main application using the extract-i18n command, it automatically imports elements marked with the i18n attribute from any associated libraries into the translation file of the main application.