Atozed Forums

Full Version: Browser Language
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

is there a way to read the language of the user browser?

I want to create a multilingual program, but so that you do not have to constantly choose your language, I would like to read the browser language in advance and set the language.

Thanks,
Michael
Hi Michael, maybe you can use UserAgent to do that ???
Code:
WebApplication.Request.UserAgent;
or
WebApplication.Browser.UserAgent;
Thanks, but from the information you can not read the set language.

I have now found a solution, but I don't think it is the best way. Big Grin

I have inserted an IWEdit and an IWTimer on the Form.
The procedure IWAppFormCreate gets the following two lines:

AddToInitProc('document.getElementById("IWEDIT1").value=navigator.language;');
AddToInitProc('AddChangedControl("IWEDIT1");');

At IWTimer1AsyncTimer I can then read the text from the IWEdit and set my program to the language.
Maybe there is a way to write the navigator.language directly into a variable of the form instead of into an IWEdit. Huh
Hi Michael,

Can't you use WebApplication.Request.AcceptLanguage?

See https://developer.mozilla.org/en-US/docs...t-Language
(01-26-2022, 02:38 PM)jeroen.rottink Wrote: [ -> ]Hi Michael,

Can't you use WebApplication.Request.AcceptLanguage?

See https://developer.mozilla.org/en-US/docs...t-Language

Hi,

that I have also already discovered and pleased. Big Grin

Unfortunately, all available languages are listed here and not which is currently selected. Sad
Templates would be very useful in addition but not necessary.

If you look in the browser agent I believe it has the language. One of the headers does.