N1CK3RS0N Posted January 16, 2009 Share Posted January 16, 2009 Greetings. I'm developing a CMS and I wanted to automatically detect browser language settings. Anyone know how to do this? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/141141-detecting-browsers-language-settings/ Share on other sites More sharing options...
premiso Posted January 16, 2009 Share Posted January 16, 2009 Greetings. I'm developing a CMS and I wanted to automatically detect browser language settings. Anyone know how to do this? Thanks Javascript is the only way I know how, since PHP is server side. Quote Link to comment https://forums.phpfreaks.com/topic/141141-detecting-browsers-language-settings/#findComment-738743 Share on other sites More sharing options...
Mark Baker Posted January 16, 2009 Share Posted January 16, 2009 if (typeof(navigator.language) != "undefined") document.writeln(navigator.language); else if (typeof(navigator.browserLanguage) != "undefined") document.writeln(navigator.browserLanguage); if (typeof(navigator.systemLanguage) == "string") document.writeln($("<div/>").text(navigator.systemLanguage).html()); if (typeof(navigator.userLanguage) == "string") document.writeln($("<div/>").text(navigator.userLanguage).html()); if (typeof(navigator.browserLanguage) == "string") document.writeln($("<div/>").text(navigator.browserLanguage).html()); Quote Link to comment https://forums.phpfreaks.com/topic/141141-detecting-browsers-language-settings/#findComment-738746 Share on other sites More sharing options...
corbin Posted January 16, 2009 Share Posted January 16, 2009 You could try checking the Accept-Language header. http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html It should be in $_SERVER somewhere. Quote Link to comment https://forums.phpfreaks.com/topic/141141-detecting-browsers-language-settings/#findComment-738759 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.