Search code examples
javascriptfirefox-addonxpcom

How can i get current layout language in firefox extension with Linux/Mac?


This can be done with user32.dll on Windows. But how can i get it on Mac/Linux?


Solution

  • You should use nsILocaleService.getSystemLocale() for that:

    var localeService = Components.classes["@mozilla.org/intl/nslocaleservice;1"]
                            .getService(Components.interfaces.nsILocaleService);
    var sysLocale = localeService.getSystemLocale()
    alert(sysLocale.getCategory("NSILOCALE_MESSAGES"));
    

    This should work regardless of operating system.