Welcome! Log In Create A New Profile

Advanced

[WebDev] Detect browser language

Posted by VictorDiego 
[WebDev] Detect browser language
October 26, 2018 09:12AM
Hello,

I have a multilingual application and I would like to detect the language of the user's browser to display the first page in that language. (Then the user can select the language they prefer)

Could someone tell me how to detect that browser language?

Victor Diego
A.T. MEDTRA, S.L.
Santander-Spain
Re: [WebDev] Detect browser language
October 26, 2018 12:49PM
Hello, in theory when you select the project option "automatically select the system language when starting the application" the page loaded is in user system language. Look at [help.windev.com]


Rubén
Re: [WebDev] Detect browser language
October 26, 2018 02:11PM
Thanks Ruben.
Yes, I have the default language of the Project. In my case Spanish. On the first page of the application the user can change the language of his preference. This runs ok.

What I want is that applicattion detects the browser language and present the first page with the same language of browser. This way the user do not need to change to other language.

Best Regards,

Victor
Re: [WebDev] Detect browser language
October 26, 2018 04:37PM
Hi Victor,

In Javascript navigator.language will return the browser language.
So you can make a function:
function get_language() {
return navigator.language;
}
See https://www.w3schools.com/jsref/prop_nav_language.asp

Kind regards,
Piet
Re: [WebDev] Detect browser language
October 29, 2018 04:14PM
Thank you Piet,
I did that with a similar función:

function idiomanavegador()
{	
	var ln = window.navigator.language||navigator.browserLanguage;	
	return ln
}



Best Regards

Victor
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: