Skip to content
This repository has been archived by the owner on Nov 8, 2021. It is now read-only.

Loading Translations . json from an external npm package #50

Closed
tnicola opened this issue Jun 12, 2018 · 1 comment
Closed

Loading Translations . json from an external npm package #50

tnicola opened this issue Jun 12, 2018 · 1 comment

Comments

@tnicola
Copy link

tnicola commented Jun 12, 2018

Hi there,

All my translations files are in a external library e.g. @translations/my-translations. I cannot access to node_modules at runtime. How could I load them using @ngx-translate/http-loader?

Thanks.

@tnicola
Copy link
Author

tnicola commented Jun 18, 2018

This helped me out: https://stackoverflow.com/questions/41555624/how-to-include-assets-from-node-modules-in-angular-cli-project .

Just follow the instructions and add your external assets in Angular CLI (.angular-cli.json) like is described in the solution.

"assets": [
  "assets",
  { "glob": "**/*", "input": "../@translations/my-translations/", "output": "./translations/" }
]

These assets will be included in the dist (outDir) folder. Then simply load them with:

export function HttpLoaderFactory(http: HttpClient) {
    return new TranslateHttpLoader(http, "/translations/", ".json");
}

Closing the issue.

@tnicola tnicola closed this as completed Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant