question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Update language with url params resulted mixing page locale

See original GitHub issue

Actual 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 at configuration.module.ts:47 (Able to control explicitly by using providers: [{provide: LOCALE_ID, useValue: 'fr-FR'}])
    • First available of locale from locales at environment.prod.ts or environment.ts (Current setup using en_US as a first available locale)
  • Assume we have fr_FR as default locale from LOCALE_ID and en_US as first locale from environment.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.
    • image

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 using translateService.use or translateService.setDefaultLang which is leading translation loads in wrong order.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
dhhyicommented, Apr 29, 2020

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 😉

0reactions
anumangcommented, Apr 30, 2020

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found