Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dictionary called twice on init #462

Closed
maximelafarie opened this issue Mar 8, 2017 · 1 comment
Closed

Dictionary called twice on init #462

maximelafarie opened this issue Mar 8, 2017 · 1 comment

Comments

@maximelafarie
Copy link

I'm submitting a ... (check one with "x")

[x] bug report => check the FAQ and search github for a similar issue or PR before submitting
[ ] support request => check the FAQ and search github for a similar issue before submitting
[ ] feature request

Current behavior
If I follow the readme step 2, with the following code :

constructor(translate: TranslateService) {
    translate.setDefaultLang('fr');
    translate.use('fr');
}

Then in the dev console (network tab), we can see the dictionary is called twice :
image

Expected/desired behavior

If I comment the last line :

constructor(translate: TranslateService) {
    translate.setDefaultLang('fr');
    //translate.use('fr');
}

The dictionary is called only one time :
image

Reproduction of the problem
Follow the 2nd step of the readme.

What is the expected behavior?
Make a single call if the dictionary already loaded.

What is the motivation / use case for changing the behavior?
It could be painful if the dictionary is big.

Please tell us about your environment:
Angular2 (CLI) / Webpack

  • ngx-translate version: 6.0.0

  • Angular version: 2.4.0

  • Browser: [Chrome 56]

@ocombe
Copy link
Member

ocombe commented Mar 8, 2017

Hello, thanks for the report but I'm closing it because it is a duplicate of #397

@ocombe ocombe closed this as completed Mar 8, 2017
ocombe pushed a commit that referenced this issue Mar 23, 2017
This stops multiple requests being made for the same lang file. It will now return the same observable when making duplicate requests for the same language.

Fixes #397
Fixes #432 
Fixes #447
Fixes Greentube/localize-router#26
Fixes #462
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants