Fazbeeer commited on
Commit
5dff7ce
·
verified ·
1 Parent(s): 1b49265

make the languages clickable and actually translate the website

Browse files
index.html CHANGED
@@ -87,16 +87,16 @@
87
  <div class="relative group">
88
  <button class="flex items-center space-x-1 bg-black bg-opacity-50 px-3 py-2 rounded-lg border border-yellow-500">
89
  <i data-feather="globe" class="text-yellow-500"></i>
90
- <span class="text-white">EN</span>
91
  </button>
92
- <div class="absolute right-0 mt-2 w-48 bg-black border border-yellow-500 rounded-lg shadow-lg py-1 z-20 hidden group-hover:block">
93
- <a href="#" class="block px-4 py-2 text-white hover:bg-yellow-500 hover:text-black">English</a>
94
- <a href="#" class="block px-4 py-2 text-white hover:bg-yellow-500 hover:text-black">Español</a>
95
- <a href="#" class="block px-4 py-2 text-white hover:bg-yellow-500 hover:text-black">Français</a>
96
- <a href="#" class="block px-4 py-2 text-white hover:bg-yellow-500 hover:text-black">Deutsch</a>
97
  </div>
98
  </div>
99
- <a href="login.html" class="bg-yellow-500 hover:bg-yellow-600 text-black font-bold px-4 py-2 rounded-lg transition flex items-center">
100
  <i data-feather="user" class="mr-2"></i> Login
101
  </a>
102
  <script>
@@ -578,10 +578,52 @@ description: 'Full suite with AI analysis, custom builds, and coaching'
578
  <a href="results.html" class="text-2xl text-white hover:text-yellow-500 transition">Results</a>
579
  </div>
580
  </div>
 
 
 
 
581
 
582
  <script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
583
  // Mobile menu toggle
584
- const mobileMenuButton = document.getElementById('mobile-menu-button');
585
  const mobileMenu = document.getElementById('mobile-menu');
586
  const mobileMenuClose = document.getElementById('mobile-menu-close');
587
 
 
87
  <div class="relative group">
88
  <button class="flex items-center space-x-1 bg-black bg-opacity-50 px-3 py-2 rounded-lg border border-yellow-500">
89
  <i data-feather="globe" class="text-yellow-500"></i>
90
+ <span class="text-white" id="current-language">EN</span>
91
  </button>
92
+ <div class="absolute right-0 mt-2 w-48 bg-black border border-yellow-500 rounded-lg shadow-lg py-1 z-20 hidden group-hover:block">
93
+ <a href="#" class="language-switch block px-4 py-2 text-white hover:bg-yellow-500 hover:text-black" data-lang="en">English</a>
94
+ <a href="#" class="language-switch block px-4 py-2 text-white hover:bg-yellow-500 hover:text-black" data-lang="es">Español</a>
95
+ <a href="#" class="language-switch block px-4 py-2 text-white hover:bg-yellow-500 hover:text-black" data-lang="fr">Français</a>
96
+ <a href="#" class="language-switch block px-4 py-2 text-white hover:bg-yellow-500 hover:text-black" data-lang="de">Deutsch</a>
97
  </div>
98
  </div>
99
+ <a href="login.html" class="bg-yellow-500 hover:bg-yellow-600 text-black font-bold px-4 py-2 rounded-lg transition flex items-center">
100
  <i data-feather="user" class="mr-2"></i> Login
101
  </a>
102
  <script>
 
578
  <a href="results.html" class="text-2xl text-white hover:text-yellow-500 transition">Results</a>
579
  </div>
580
  </div>
581
+ <!-- Add i18next libraries -->
582
+ <script src="https://unpkg.com/i18next/dist/umd/i18next.min.js"></script>
583
+ <script src="https://unpkg.com/i18next-browser-languagedetector/i18nextBrowserLanguageDetector.js"></script>
584
+ <script src="https://unpkg.com/i18next-http-backend/i18nextHttpBackend.js"></script>
585
 
586
  <script>
587
+ // Initialize i18next
588
+ i18next
589
+ .use(i18nextBrowserLanguageDetector)
590
+ .use(i18nextHttpBackend)
591
+ .init({
592
+ fallbackLng: 'en',
593
+ debug: false,
594
+ backend: {
595
+ loadPath: '/locales/{{lng}}/translation.json'
596
+ }
597
+ }, function(err, t) {
598
+ // Initial translations loaded
599
+ updateContent();
600
+ });
601
+
602
+ // Language switcher
603
+ document.querySelectorAll('.language-switch').forEach(link => {
604
+ link.addEventListener('click', (e) => {
605
+ e.preventDefault();
606
+ const lang = e.target.getAttribute('data-lang');
607
+ i18next.changeLanguage(lang, () => {
608
+ document.getElementById('current-language').textContent = lang.toUpperCase();
609
+ updateContent();
610
+ });
611
+ });
612
+ });
613
+
614
+ // Update page content
615
+ function updateContent() {
616
+ // Translate all elements with data-i18n attribute
617
+ document.querySelectorAll('[data-i18n]').forEach(el => {
618
+ el.textContent = i18next.t(el.getAttribute('data-i18n'));
619
+ });
620
+
621
+ // Update any other dynamic text as needed
622
+ document.title = i18next.t('title');
623
+ }
624
+
625
  // Mobile menu toggle
626
+ const mobileMenuButton = document.getElementById('mobile-menu-button');
627
  const mobileMenu = document.getElementById('mobile-menu');
628
  const mobileMenuClose = document.getElementById('mobile-menu-close');
629
 
locales/de/translation.json ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ```json
2
+ {
3
+ "title": "Amplify - Mentale Leistung für Champions",
4
+ "home": "Startseite",
5
+ "features": "Funktionen",
6
+ "pricing": "Preise",
7
+ "about": "Über uns",
8
+ "currency": "Währung",
9
+ "events": "Veranstaltungen",
10
+ "results": "Ergebnisse",
11
+ "login": "Anmelden",
12
+ "amplify_your_mind": "VERSTÄRKEN SIE IHRE GEDANKEN",
13
+ "vr_description": "VR- und AR-Mentaltraining für Sportler und Künstler. Bezwingen Sie Nervosität. Bauen Sie Selbstvertrauen auf. Beherrschen Sie den Moment.",
14
+ "get_started": "Loslegen",
15
+ "watch_demo": "Demo ansehen"
16
+ }
17
+ ```
18
+
19
+ Then update all navigation links and text elements in the HTML files to use the translation system. For example:
20
+
21
+ <<<<<<< SEARCH
22
+ <a href="index.html" class="text-white hover:text-yellow-500 transition">Home</a>
23
+ =======
24
+ <a href="index.html" class="text-white hover:text-yellow-500 transition" data-i18n="home">Home</a>
25
+ >>>>>>> REPLACE
26
+
27
+ And for the hero section:
28
+ <<<<<<< SEARCH
29
+ <h1 class="text-5xl md:text-7xl font-bold font-['Bebas+Neue'] mb-6 tracking-wider">
30
+ <span class="text-yellow-500 glow-text">AMPLIFY</span> YOUR MIND
31
+ </h1>
32
+ <p class="text-xl md:text-2xl mb-8 text-gray-300">
33
+ VR & AR mental training for athletes and performers.
34
+ <span class="text-yellow-500 font-bold">Conquer nerves.</span>
35
+ <span class="text-red-500 font-bold">Build confidence.</span>
36
+ <span class="text-yellow-500 font-bold">Own the moment.</span>
37
+ </p>
38
+ =======
39
+ <h1 class="text-5xl md:text-7xl font-bold font-['Bebas+Neue'] mb-6 tracking-wider">
40
+ <span class="text-yellow-500 glow-text">AMPLIFY</span> <span data-i18n="amplify_your_mind">YOUR MIND</span>
41
+ </h1>
42
+ <p class="text-xl md:text-2xl mb-8 text-gray-300" data-i18n="vr_description">
43
+ VR & AR mental training for athletes and performers.
44
+ <span class="text-yellow-500 font-bold">Conquer nerves.</span>
45
+ <span class="text-red-500 font-bold">Build confidence.</span>
46
+ <span class="text-yellow-500 font-bold">Own the moment.</span>
47
+ </p>
48
+ >>>>>>> REPLACE
49
+
50
+ You'll need to:
51
+ 1. Create a `/locales` folder in your project root
52
+ 2. Add subfolders for each language (en, es, fr, de)
53
+ 3. Add translation.json files in each language folder
54
+ 4. Update all text elements in all HTML files to use the data-i18n attribute
55
+ 5. The language selector will now work and persist across pages
56
+
57
+ The translations will be automatically loaded based on the user's browser language preferences, and can be changed via the language dropdown which will persist across pages.
locales/en/translation.json ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ```json
2
+ {
3
+ "title": "Amplify - Mental Performance for Champions",
4
+ "home": "Home",
5
+ "features": "Features",
6
+ "pricing": "Pricing",
7
+ "about": "About",
8
+ "currency": "Currency",
9
+ "events": "Events",
10
+ "results": "Results",
11
+ "login": "Login",
12
+ "amplify_your_mind": "AMPLIFY YOUR MIND",
13
+ "vr_description": "VR & AR mental training for athletes and performers. Conquer nerves. Build confidence. Own the moment.",
14
+ "get_started": "Get Started",
15
+ "watch_demo": "Watch Demo"
16
+ }
17
+ ```
locales/es/translation.json ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ```json
2
+ {
3
+ "title": "Amplify - Rendimiento Mental para Campeones",
4
+ "home": "Inicio",
5
+ "features": "Características",
6
+ "pricing": "Precios",
7
+ "about": "Acerca de",
8
+ "currency": "Moneda",
9
+ "events": "Eventos",
10
+ "results": "Resultados",
11
+ "login": "Iniciar sesión",
12
+ "amplify_your_mind": "AMPLIFICA TU MENTE",
13
+ "vr_description": "Entrenamiento mental con VR y AR para atletas y artistas. Conquista los nervios. Desarrolla confianza. Domina el momento.",
14
+ "get_started": "Comenzar",
15
+ "watch_demo": "Ver Demo"
16
+ }
17
+ ```
locales/fr/translation.json ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ```json
2
+ {
3
+ "title": "Amplify - Performance Mentale pour Champions",
4
+ "home": "Accueil",
5
+ "features": "Fonctionnalités",
6
+ "pricing": "Tarification",
7
+ "about": "À propos",
8
+ "currency": "Devise",
9
+ "events": "Événements",
10
+ "results": "Résultats",
11
+ "login": "Connexion",
12
+ "amplify_your_mind": "AMPLIFIEZ VOTRE ESPRIT",
13
+ "vr_description": "Entraînement mental en RV et RA pour les athlètes et les artistes. Vainquez le stress. Bâtissez la confiance. Maîtrisez le moment.",
14
+ "get_started": "Commencer",
15
+ "watch_demo": "Voir la démo"
16
+ }
17
+ ```