Custom Language Order
-
Hi
I want to display languages in a custom order. My site includes a total of 9 languages, with English being the main language. I am currently using the shortcode to show the languages in the navigation menu as a click to popup. Currently languages are showing in chronological order or i’m not sure which order.The desired order of languages is:
- Spanish
- English
- Arabic
- Nederlandse
- French
- German
- Chinese
- Russian
- Turkish
I’ve tried the following approach using JavaScript to reorder the languages, but it didn’t work:
document.addEventListener('DOMContentLoaded', function() {
var languages = [
{ code: 'es', name: 'Espa?ol' },
{ code: 'en', name: 'English' },
{ code: 'ar', name: '???????' },
{ code: 'nl', name: 'Nederlands' },
{ code: 'fr', name: 'Fran?ais' },
{ code: 'de', name: 'Deutsch' },
{ code: 'zh-CN', name: '简体中文' },
{ code: 'ru', name: 'Русский' },
{ code: 'tr', name: 'Türk?e' }
];
var languageSelector = document.querySelector('.gtranslate_wrapper select');
console.log('Language Selector:', languageSelector); // Debugging line
if (languageSelector) {
languageSelector.innerHTML = '';
languages.forEach(function(language) {
var option = document.createElement('option');
option.value = language.code;
option.textContent = language.name;
languageSelector.appendChild(option);
});
} else {
console.log('Language selector not found.');
}
});Could you please assist me in configuring the languages to display in the custom order mentioned above? Any guidance or suggestions would be greatly appreciated.
Thanks so much!
The page I need help with: [log in to see the link]
- The topic ‘Custom Language Order’ is closed to new replies.