Update language with url params resulted mixing page locale
See original GitHub issueActual Behavior
Using lang
parameter depending on configuration set-up causing mixed page locale selection.
Expected Behavior
Given language by using lang
parameter should reflect completely on current page locale without depending on your environment setup.
Steps to Reproduce the Bug Strange behaviour exist if follow steps to set-up environment and execute;
- Set-up different initial locales between;
LOCALE_ID
which is used to set default locale atconfiguration.module.ts:47
(Able to control explicitly by usingproviders: [{provide: LOCALE_ID, useValue: 'fr-FR'}]
)- First available of locale from locales at
environment.prod.ts or environment.ts
(Current setup usingen_US
as a first available locale)
- Assume we have
fr_FR
as default locale fromLOCALE_ID
anden_US
as first locale fromenvironment.prod.ts or environment.ts
- Run application,
npm start
- Try to navigate
http://localhost:4200/home;lang=fr_FR
- See mixing over selected locale and page content.
Environment Details
Desktop:
- Chrome 80.0.3987.163
- PWA 0.18
Possible Root Cause
- Application causing repeating language switch within short period of time, which triggers known
ngx-translate
issue ngx-translate/core#1030, - As a result application state switched correct language, loaded translation may differs,
- Adding defer times while switching language like using
debounceTime
or removing possible repeated language switch with same language code two times or more by usingtranslateService.use or translateService.setDefaultLang
which is leading translation loads in wrong order.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Multi-Regional and Multilingual Sites | Google Search Central
Multi-regional and multilingual sites can be optimized for Search. Learn more about managing SEO for sites with multiple languages.
Read more >A way to add the language parameter to the URL #325 - GitHub
My wish is to make the additional possibility to switch the languages with the URL parameter. I.e. www.example.com/en/something ...
Read more >Change route params without reloading in Angular 2
As of RC6 you can do the following to change URL without change state and thereby keeping your route history import {OnInit} from...
Read more >URL parameters of the Google search engine results page
It is worth noting that when you use the operators cr and gl in top issue are mixed sites of the region or...
Read more >API — tweepy 4.12.1 documentation
next – This parameter is used to get the next 'page' of results. ... locale – Specify the language of the query you...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes, NOW I get it. Sorry it took me so long, must be one of my bad days. 😅
Debouncing actually works. Just re-scheduling with delay zero does also work for me. Can you please double-check? Thank you for pointing me the right way.
Do you mind if I add you as an author to that commit? #karma 😉
@dhhyi, thank you for understanding and resolving the issue 🎉.
At the end, We just made a temporary solution but still I am happy to be part of it 😃 So it’s not necessity but as you wish if you count me as an author for this fix.
My long term expectations,
Translation library should bring stable fix for their issue if they decide to wont-fix for their race condition issue and suggest developers to update locales only once, you may need to re-evaluate ISH locales architecture / logic from scratch or may switch another possible solutions which you mentioned with possible changes after angular 9 upgrade.