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

Duplicate requests when using use & setDefaultLang #447

Closed
deeg opened this issue Feb 24, 2017 · 3 comments
Closed

Duplicate requests when using use & setDefaultLang #447

deeg opened this issue Feb 24, 2017 · 3 comments

Comments

@deeg
Copy link
Contributor

deeg commented Feb 24, 2017

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

translate.setDefaultLang('en');
translate.use(browserLang.match(/en|fr/) ? browserLang : 'en');

Expected/desired behavior

The en.json file should only load once. I know you can wait for .use to complete by subscribing to it and calling setDefaultLang file after, but I was wondering if you wanted to take a different approach in the library:

  • When the library starts to fetch a translation file, do not fetch any more until that is complete.

I can look into putting out a PR for this, but wanted to see your thoughts before I started. Is this something that should be handled by the lib, or should the user be the one to make sure you aren't calling setDefault and use at the same time for the same language?

Please tell us about your environment:

  • ngx-translate version: 6.0.0

  • Angular version: 2.4.8

@SamVerschueren
Copy link
Contributor

duplicate #397 (comment)

@deeg
Copy link
Contributor Author

deeg commented Feb 24, 2017

Sorry about that, I did try searching too!

@SamVerschueren
Copy link
Contributor

No problem :)

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants