Skip to content

Commit

Permalink
Merge pull request #243 from ec-jrc/Language-by-default-#238
Browse files Browse the repository at this point in the history
#238 Change default language
  • Loading branch information
oruscalleda authored Dec 23, 2022
2 parents b64c8cd + d0f4bdf commit e42ce65
Showing 1 changed file with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,29 @@ function initLocalization(selector) {
currentLanguage = (storedLanguage !== val_emptyString) ? storedLanguage : getBrowserLanguage();

}


// Get the JSON that contains the active language list
let JSONLINK = registryApp.hostURL + "/rest?lang=active&format=jsonc"
unparsedLanguageJSON = $.ajax({
url: JSONLINK,
async: false
}).responseText;

var languageJSON = JSON.parse(unparsedLanguageJSON);
var languageAvailable = false;

// Checking if the current language is active
for(var i=0; i<languageJSON.length;i++){
if(currentLanguage === languageJSON[i].iso6391code){
languageAvailable = true;
}
}
// If not available set default
if(! languageAvailable){
currentLanguage = 'en';
}


// Storing the language to the cookie if needed
if ((storedLanguage === null || typeof storedLanguage === val_undefined || storedLanguage === val_emptyString)
// && navigator.cookieEnabled
Expand Down

0 comments on commit e42ce65

Please sign in to comment.