Can't get current language with translate.getBrowserLang(), it always return the same value
See original GitHub issueI want to get current language with this.translate.getBrowserLang()
, but it always return ‘en’, but the app’s language actually changed, here is the plunkr
https://plnkr.co/edit/JEXgj8WcISYGtDg75VoR?p=preview ,and this is from the demo plunkr
here is my version:
"@ngx-translate/core": "^6.0.0",
"@ngx-translate/http-loader": "^0.0.3",
Issue Analytics
- State:
- Created 7 years ago
- Comments:8
Top Results From Across the Web
How to get current language with ngx-translate in angular2
I want to get current language with this.translate.getBrowserLang() , but it always return 'en', whatever the current language is and what ...
Read more >How to translate your Angular app with ngx-translate
1. Add ngx-translate to your Angular application 2. Set up the TranslateService in your app.module.ts 3. Create your main language translation file (in...
Read more >Angular Localization Using ngx-translate - Telerik
Use the below method of TranslateService to get current browser language to set the default language. const currentLanguage = this.translate.
Read more >Using ngx-translate to switch the language of a Form in your ...
Now since i have used just 2 languages, I will have 2 json files located in the i18n folder in the assets folder....
Read more >@ngx-translate/core - npm
Define the default language for the application ... Without any onTranslationChange events this returns the same value as get but it will ...
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
.getBrowserLang()
returns the FIRST default browser language. I just changed my chrome from"de"
to"en"
…ok…working. I wanted to change back to"de"
, but the german language was gone in the chrome settings, so i added it again and set it as the default browser language. After all of that, the.getBrowserLang()
still returns"en"
, because my"de"
setting was the last of three["en-us", "en", "de"]
, and the.getBrowserLang()
only returns the first browser language, but NOT the one which is set as the default language.Like its name suggests,
getBrowserLang
returns the lang of the browser. If you want the lang setup for your application usethis.translate.currentLang
.