Skip to content

Commit bd133ea

Browse files
committed
Update index.html
1 parent 986b564 commit bd133ea

File tree

1 file changed

+35
-7
lines changed

1 file changed

+35
-7
lines changed

index.html

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -369,10 +369,17 @@ <h2 id="installation" class="lang" data-en="Installation and Getting Started" da
369369
<a href="https://github.com/tinystruct/tinystruct" class="btn" target="_blank">GitHub Repository</a>
370370
<a href="https://mvnrepository.com/artifact/org.tinystruct/tinystruct" class="btn" target="_blank">Maven Repository</a>
371371

372-
<h2>Why Choose Tinystruct?</h2>
373-
<p>
374-
tinystruct focuses on reducing unnecessary complexity in application development.
375-
Its lightweight, modular nature makes it an excellent choice for developers looking for a straightforward, efficient framework for various Java-based projects.
372+
<h2 class="lang"
373+
data-en="Why Choose tinystruct?"
374+
data-de="Warum tinystruct wählen?"
375+
data-fr="Pourquoi choisir tinystruct?"
376+
data-zh="为什么选择 tinystruct?">
377+
</h2>
378+
<p class="lang"
379+
data-en="tinystruct focuses on reducing unnecessary complexity in application development. Its lightweight, modular nature makes it an excellent choice for developers looking for a straightforward, efficient framework for various Java-based projects."
380+
data-de="tinystruct konzentriert sich darauf, unnötige Komplexität in der Anwendungsentwicklung zu reduzieren. Seine leichte, modulare Natur macht es zu einer ausgezeichneten Wahl für Entwickler, die nach einem einfachen, effizienten Framework für verschiedene Java-basierte Projekte suchen."
381+
data-fr="tinystruct se concentre sur la réduction de la complexité inutile dans le développement d'applications. Sa nature légère et modulaire en fait un excellent choix pour les développeurs à la recherche d'un cadre simple et efficace pour divers projets basés sur Java."
382+
data-zh="tinystruct 专注于减少应用程序开发中的不必要复杂性。其轻量级、模块化的特性使其成为开发人员在寻找简洁高效的 Java 项目框架时的理想选择。">
376383
</p>
377384
</div>
378385

@@ -390,13 +397,34 @@ <h2>Why Choose Tinystruct?</h2>
390397
menu.classList.toggle('active');
391398
}
392399

393-
// Language Change Function
400+
// Change language based on user selection
394401
function changeLanguage(lang) {
395-
document.querySelectorAll('.lang').forEach(element => {
396-
element.innerText = element.getAttribute('data-' + lang);
402+
const elements = document.querySelectorAll('.lang');
403+
elements.forEach(element => {
404+
const translation = element.dataset[lang];
405+
if (translation) {
406+
element.innerHTML = translation;
407+
}
397408
});
409+
410+
// Update URL fragment with selected language
411+
window.location.hash = lang;
412+
}
413+
414+
// Check URL fragment for language code and apply it
415+
function applyLanguageFromURL() {
416+
const hash = window.location.hash.substring(1); // Get language code from the URL fragment
417+
const validLanguages = ['en', 'fr', 'de', 'zh']; // Define valid languages
418+
419+
if (validLanguages.includes(hash)) {
420+
const select = document.querySelector('.language-select');
421+
select.value = hash;
422+
changeLanguage(hash); // Apply the language change
423+
}
398424
}
399425

426+
// Add event listener to load language on page load
427+
window.addEventListener('DOMContentLoaded', applyLanguageFromURL);
400428
// Copy Code Function
401429
function copyCode(button) {
402430
const codeBlock = button.previousElementSibling;

0 commit comments

Comments
 (0)