diff --git a/scripts/removeMultilang.js b/scripts/removeMultilang.js new file mode 100644 index 0000000..d885069 --- /dev/null +++ b/scripts/removeMultilang.js @@ -0,0 +1,72 @@ +const fs = require("fs"); +const path = require("path"); +const languages = require("../src/config/language.json"); + +// Filter out the English language +const englishLang = languages.filter((item) => item.languageCode === "en"); +const filterLangs = languages.filter((item) => item.languageCode !== "en"); +const contentDir = "src/content"; +const configDir = "src/config"; +const i18nDir = "src/i18n"; + +// Update language.json to only include the English language +fs.writeFileSync( + path.join(configDir, "language.json"), + JSON.stringify(englishLang, null, 2), +); + +// Remove content directories for languages other than English +filterLangs.forEach((lang) => { + const langContentDir = path.join(contentDir, lang.contentDir); + fs.rm(langContentDir, { recursive: true, force: true }, (err) => { + if (err) { + console.error(`Error deleting folder ${langContentDir}:`, err); + return; + } + console.log(`Folder ${langContentDir} deleted successfully`); + }); +}); + +// Remove other menu.{lang}.json files except menu.en.json +fs.readdir(configDir, (err, files) => { + if (err) { + console.error("Error reading config directory:", err); + return; + } + + files.forEach((file) => { + if (file.startsWith("menu.") && file !== "menu.en.json") { + const filePath = path.join(configDir, file); + fs.unlink(filePath, (err) => { + if (err) { + console.error(`Error deleting file ${filePath}:`, err); + return; + } + console.log(`File ${filePath} deleted successfully`); + }); + } + }); +}); + +// Remove other language files from i18n folder except en.json +fs.readdir(i18nDir, (err, files) => { + if (err) { + console.error("Error reading i18n directory:", err); + return; + } + + files.forEach((file) => { + if (file !== "en.json") { + const filePath = path.join(i18nDir, file); + fs.unlink(filePath, (err) => { + if (err) { + console.error(`Error deleting file ${filePath}:`, err); + return; + } + console.log(`File ${filePath} deleted successfully`); + }); + } + }); +}); + +console.log("Cleanup completed."); diff --git a/src/layouts/partials/Header.astro b/src/layouts/partials/Header.astro index 918df56..2b13100 100755 --- a/src/layouts/partials/Header.astro +++ b/src/layouts/partials/Header.astro @@ -2,6 +2,7 @@ import Logo from "@/components/Logo.astro"; import ThemeSwitcher from "@/components/ThemeSwitcher.astro"; import config from "@/config/config.json"; +import languages from "@/config/language.json"; import LanguageSwitcher from "@/helpers/LanguageSwitcher"; import { constructUrl, @@ -158,7 +159,12 @@ const { get_started } = await getTranslations(lang as keyof ContentEntryMap); ) } - + { + languages.length > 1 && ( + + ) + } + { navigation_button.enable && (