Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign up[i18n] how to best support a library author providing translations for their library #36757
Comments
|
I am working on a PR that would support merging multiple translation files when translating an application. So if a library author provided a set of translation files it would be possible to combine them with the application translations. This would then need to be integrated into the Angular CLI. Further, we should look into how best to make this seamless. For instance agreeing on a file naming convention (or perhaps a property in |
|
I also have a PR in the works for doing |
|
Can we use merging multiple translation files in angular 10? By the way, is the dynamic switching of languages not supported by ivy? |
|
We intend to use
We can work around this problem by redeclaring the global in the library and I've made a request here to have that in DT instead, to be able to add the following to the library's tsconfig:
But what is the intended way to inform typescript about the presence this global when there is no |
|
@sorohan you only need to include this import in any one of your TS files so the compiler to pick up the typing of global |
|
@petebacondarwin wouldn't that be better if that import was just the typing, and not also effectful (it is actually adding |
|
So it is true that this could leave the global function in your final application bundle. I believe that it adds about 850 bytes once it is minified. If you are doing compile-time translation, then the In Angular CLI builds we actually strip out this JS by configuring webpack. I believe the approach used is to intercept the import and return an empty string instead of the original file. See https://github.com/angular/angular-cli/blob/c8915f42055b7fcefbafbcd64b06bbc6aecf778a/packages/angular_devkit/build_angular/src/utils/webpack-browser-config.ts#L148-L157 |
|
Thanks for the info, it's very helpful. Is using |
|
It is still not strictly public... I think the aim will be for it to be so by 10.1.0. Thanks for bringing it up. |
|
I think you might be able to do: import type {} from '@angular/localize/init'; |
|
Actually, having just played with this a bit, it seems that ng-packagr will not pull in the imported Be aware that adding |


We should discuss how to best support a library author providing translations for their library.