Hi I have an angular 2 project internationalized with ng2-translate, it works fine but in all my module I have imported translatemodule ecc... So now the app call selectedLanguage.json in every page clicked. Is there a way to charge the translation only at the application start? And maybe to import module only in the root module?
Asked
Active
Viewed 406 times
0
-
using ngx-translate instead, https://github.com/ngx-translate/core#usage – Tiep Phan Apr 20 '17 at 12:43
-
Can you tell me why? – Alessandro Celeghin Apr 20 '17 at 12:47
-
ngx-translate is newer version of ng2-translate, and it come from same guy, who create ng2-translate, with a lot of bug fixing, and support lazy load better. – Tiep Phan Apr 20 '17 at 13:17
-
But with ngx can I load translation only 1 time? and not with every page loads? – Alessandro Celeghin Apr 20 '17 at 13:21
-
you can config using same instance – Tiep Phan Apr 20 '17 at 13:36
1 Answers
1
You problem is most likely that you are importing ng2-translate in a module for every component. So each component has it's own copy of ng2-translate and each instance is fetching the translations. I would suggests only importing ng2-translate at your root module(app.module.ts) so that you only have one copy shared across your application.

cmaynard
- 2,852
- 2
- 24
- 34