Skip to content

Commit

Permalink
Added more languagues
Browse files Browse the repository at this point in the history
  • Loading branch information
JollyJolli authored Oct 30, 2024
1 parent 54a6983 commit 240f8f9
Showing 1 changed file with 79 additions and 29 deletions.
108 changes: 79 additions & 29 deletions JS/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ async function fetchProjectsData() {
const response = await fetch('https://raw.githubusercontent.com/JollyJolli/json-db/refs/heads/main/data/webs/web-places.json');
const data = await response.json();
projects = data.Webs; // Store the fetched projects data
displayProjects(projects); // Display projects after fetching
displayProjects(projects, currentFilter, currentLanguage); // Display projects after fetching
} catch (error) {
console.error('Error fetching projects data:', error);
}
Expand Down Expand Up @@ -64,8 +64,9 @@ function setupFilterButtons() {
// Add active class to the clicked button
button.classList.add('active');

// Display filtered projects
displayProjects(projects, filter, currentLanguage);
// Update current filter and display filtered projects
currentFilter = filter;
displayProjects(projects, currentFilter, currentLanguage);
});
});
}
Expand All @@ -87,32 +88,81 @@ function changeLanguage(language) {
const landingWall = document.getElementById("landing-wall");

// Update text based on selected language
if (language === "en") {
title.textContent = title.dataset.en;
discordBtn.textContent = discordBtn.dataset.en;
landingWall.textContent = landingWall.dataset.en;
description.textContent = description.dataset.en;
projectsTitle.textContent = projectsTitle.dataset.en;

// Update filter button text
document.getElementById("filter-all").textContent = "All";
document.getElementById("filter-new").textContent = "New";
document.getElementById("filter-updated").textContent = "Updated";
document.getElementById("filter-contributed").textContent = "Contributed";
document.getElementById("filter-else").textContent = "Others";
} else if (language === "es") {
title.textContent = title.dataset.es;
description.textContent = description.dataset.es;
projectsTitle.textContent = projectsTitle.dataset.es;
discordBtn.textContent = discordBtn.dataset.es;
landingWall.textContent = landingWall.dataset.es;

// Update filter button text
document.getElementById("filter-all").textContent = "Todos";
document.getElementById("filter-new").textContent = "Nuevos";
document.getElementById("filter-updated").textContent = "Actualizados";
document.getElementById("filter-contributed").textContent = "Contribuidos";
document.getElementById("filter-else").textContent = "Otros";
switch (language) {
case "en":
title.textContent = title.dataset.en;
discordBtn.textContent = discordBtn.dataset.en;
landingWall.textContent = landingWall.dataset.en;
description.textContent = description.dataset.en;
projectsTitle.textContent = projectsTitle.dataset.en;

// Update filter button text
document.getElementById("filter-all").textContent = "All";
document.getElementById("filter-new").textContent = "New";
document.getElementById("filter-updated").textContent = "Updated";
document.getElementById("filter-contributed").textContent = "Contributed";
document.getElementById("filter-else").textContent = "Others";
break;

case "es":
title.textContent = title.dataset.es;
description.textContent = description.dataset.es;
projectsTitle.textContent = projectsTitle.dataset.es;
discordBtn.textContent = discordBtn.dataset.es;
landingWall.textContent = landingWall.dataset.es;

// Update filter button text
document.getElementById("filter-all").textContent = "Todos";
document.getElementById("filter-new").textContent = "Nuevos";
document.getElementById("filter-updated").textContent = "Actualizados";
document.getElementById("filter-contributed").textContent = "Contribuidos";
document.getElementById("filter-else").textContent = "Otros";
break;

case "fr":
title.textContent = title.dataset.fr;
description.textContent = description.dataset.fr;
projectsTitle.textContent = projectsTitle.dataset.fr;
discordBtn.textContent = discordBtn.dataset.fr;
landingWall.textContent = landingWall.dataset.fr;

// Update filter button text
document.getElementById("filter-all").textContent = "Tous";
document.getElementById("filter-new").textContent = "Nouveaux";
document.getElementById("filter-updated").textContent = "Mis à jour";
document.getElementById("filter-contributed").textContent = "Contribués";
document.getElementById("filter-else").textContent = "Autres";
break;

case "it":
title.textContent = title.dataset.it;
description.textContent = description.dataset.it;
projectsTitle.textContent = projectsTitle.dataset.it;
discordBtn.textContent = discordBtn.dataset.it;
landingWall.textContent = landingWall.dataset.it;

// Update filter button text
document.getElementById("filter-all").textContent = "Tutti";
document.getElementById("filter-new").textContent = "Nuovi";
document.getElementById("filter-updated").textContent = "Aggiornati";
document.getElementById("filter-contributed").textContent = "Contribuiti";
document.getElementById("filter-else").textContent = "Altri";
break;

case "pt":
title.textContent = title.dataset.pt;
description.textContent = description.dataset.pt;
projectsTitle.textContent = projectsTitle.dataset.pt;
discordBtn.textContent = discordBtn.dataset.pt;
landingWall.textContent = landingWall.dataset.pt;

// Update filter button text
document.getElementById("filter-all").textContent = "Todos";
document.getElementById("filter-new").textContent = "Novos";
document.getElementById("filter-updated").textContent = "Atualizados";
document.getElementById("filter-contributed").textContent = "Contribuídos";
document.getElementById("filter-else").textContent = "Outros";
break;
}
}

Expand Down

0 comments on commit 240f8f9

Please sign in to comment.