Is it possible to determine the browser language setting of a guest user on an external site from Apex or VF?

I'm leveraging custom labels and they seem to respond to the browser language setting of a guest user, however I also have some dynamic picklist values that I need to display in the correct language as well. Has anyone had experience with this or know of a way to get the browser language setting value?


1 Answer 1


The normal way to get that value is by Accept-Language request header.

I think this is not possible to get by Apex.


//this is returning null

A possible workaround could be to get it on VF using this technique in javascript

var language = window.navigator.userLanguage || window.navigator.language; //works on IE/CH/FF
  //other browsers gonna be a little tricky
    url: "http://ajaxhttpheaders.appspot.com", 
    dataType: 'jsonp', 
    success: function(headers) {
        language = headers['Accept-Language'];

Once you have the language you could rerender the picklist using a

  • 1
    ApexPages.currentPage().getHeaders().get('Accept-Language'); worked fine for me, thanks!
    – Phil B
    Jun 27, 2013 at 19:35
  • Great @PhilB, which API version are you using? Jun 27, 2013 at 22:19
  • That class is using API version 25
    – Phil B
    Jul 10, 2013 at 21:03
  • Just implemented ApexPages.currentPage().getHeaders().get('Accept-Language'); in a multilingual site and it's working for Chrome, Firefox, Safari and Edge. Mar 21, 2018 at 11:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.