Reputation: 43
I am building Angular 6 application with 3 libraries ...
I would like to have 3 json files containing translations in each of them.
Is it possible to have TranslateLoader that reads those files from installed libraries. So that I could say something like
new TranslateLibraryLoader(http, ["@company/lib1", "@company/lib2",
"@company/lib3", "./assets/i18n/"]
Upvotes: 2
Views: 1228
Reputation: 1067
ngx-translate needs the files from the libraries at runtime. So first you have to tell angular to integrate these files in your build. In your angular.json
do:
"assets": [
{
"input": "./path-to-company/lib1/translations.json",
"bundleName": "translations.lib1.json",
"lazy": true
},
// repeat for all libs
],
Then you can configure a TranslateHttpLoader to load these files or implement your own one:
export function HttpLoaderFactory(http: HttpClient) {
return new TranslateHttpLoader(http, yourPath, yourSuffix);
}
Upvotes: 2