fbpx
Skip to content
Questions & AnswersCategory: QuestionsGet active language method
Stefan asked 8 years ago
I am missing a method which would return current active language code. I know I can retrieve it from a cookie but it would be a nice feature to have this method already integrated in a generated code or is there some special reason why this method was left out. This can come very handy when we need to preset active language in the language menu. Here is code I have used, it is basically just a copy and paste from your method runUpdate
function getActiveLanguage() {
    var currentlanguage=0; // firstlanguage
    
    if (readCookie('language') != '' && typeof Number(readCookie('language')) == 'number') {
        currentlanguage=Number(readCookie('language'));
    } else {
        jQuery.browserLanguage(function( language , acceptHeader ){
            try {
                  createCookie('language', mllanguages[language], 30);
                  currentlanguage=mllanguages[language];
            } catch(e) {currentlanguage=0;}
        });         
    }
  
    if (isNaN(currentlanguage)) {
        currentlanguage = 0;
    }
    
    return currentlanguage;
}
1 Answers
answered 7 years ago

Hey Stefan,
 
were you able to resolve this issue? Do you still need help? If so, let me know here and I’ll help you asap.

We use cookies

We use cookies for various things on our site, including our on-site chat bubble (if you use it), our comment forms (if you use them) and for session handling (if you log in).

Other than that, we use cookies to identify where traffic came from to help us understand which traffic turns into sales, we use a cookie for Google Analytics traffic analysis and we use a cookie to customise adverts for our own products we think you'll be interested in.

You can read more detail in our privacy policy page. Please click 'Accept' or 'Decline' to continue.