core
core copied to clipboard
How to localize content coming from third party libraries in Angular
I am using multiple libraries in my angular application. I want to understand how I can localize contents coming from these libraries or is there a way to load their translation files in the application? I want to load the library translation files as and when used.
Hi @tarushreeS, You can indeed export assets file from your library into a new one.
Here's an example on how to do it. https://stackoverflow.com/a/64589400/11135174.
For you, you just have to move the i18n files into the assets folder and then reference it like that.
// app.module.ts
export function HttpLoaderFactory(http: HttpClient) {
return new MultiTranslateHttpLoader(http, ['/assets/i18n/', '/assets/vendors/i18n/'])
}
// angular.json
"assets": [
"src/assets",
{
"glob": "**/*.json",
"input": "node_modules/@your-library/project-name/assets",
"output": "/assets/vendors/i18n/"
},
@ocombe I think you shall close this issue