Skip to content

Commit

Permalink
Select improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Muhaddil committed May 3, 2024
1 parent 3cea55e commit 99a05b7
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions JS/glyphgeneratorV3.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,6 @@ export const displayRandomGlyphs = () => {
// Make the displayRandomGlyphs function globally accessible
window.displayRandomGlyphs = displayRandomGlyphs;

// Function to change language
window.changeLanguage = () => {
const lang = document.getElementById("lang").value;
i18next.changeLanguage(lang);
localStorage.setItem("i18nextLng", lang);
$("body").localize();
};

// Function to populate the language options
const populateLanguageOptions = () => {
const select = document.getElementById("lang");
Expand All @@ -78,6 +70,14 @@ const populateLanguageOptions = () => {
});
};

// Function to change language
window.changeLanguage = () => {
const lang = document.getElementById("lang").value;
i18next.changeLanguage(lang);
localStorage.setItem("i18nextLng", lang);
$("body").localize();
};

// Initialize i18next
i18next.init(
{
Expand Down Expand Up @@ -106,11 +106,11 @@ i18next.init(
// Translate the entire body
$("body").localize();

// This selects the correct language option in the select
const lang = i18next.language;
document.getElementById("lang").value = lang;

// This autopopulates the language options in the select
populateLanguageOptions();

// This selects the correct language option in the select
const lang = localStorage.getItem("i18nextLng") || i18next.language; // Get the selected language from local storage
document.getElementById("lang").value = lang;
}
);

0 comments on commit 99a05b7

Please sign in to comment.