|
1 | 1 | import i18n from "i18next"; |
2 | 2 | import { initReactI18next } from "react-i18next"; |
3 | 3 | import LanguageDetector from "i18next-browser-languagedetector"; |
| 4 | +import { cardsData } from "../data/cardsData"; |
4 | 5 |
|
5 | 6 | i18n |
6 | 7 | .use(LanguageDetector) |
|
9 | 10 | resources: { |
10 | 11 | en: { |
11 | 12 | translation: { |
12 | | - marv: { |
13 | | - description: |
14 | | - "A Discord bot in NodeJS that uses ChatGPT and a speech synthesis and recognition system, allowing interaction with the bot through voice commands.", |
15 | | - }, |
16 | 13 | info: "Our projects", |
17 | 14 | baseline: "Software & Script Development", |
18 | 15 | discord: "Join our Discord", |
|
21 | 18 | }, |
22 | 19 | fr: { |
23 | 20 | translation: { |
24 | | - marv: { |
25 | | - description: |
26 | | - "Un bot Discord en NodeJS qui utilise chatGPT et un système de synthèse et de reconnaissance vocale permettant d’intéragir avec le bot grâce à la voix.", |
27 | | - }, |
28 | | - |
29 | 21 | info: "Nos projets", |
30 | 22 | baseline: "Développement de softs & scripts", |
31 | 23 | discord: "Rejoignez notre Discord", |
32 | 24 | devby: "Developpé par", |
33 | 25 | }, |
34 | 26 | }, |
| 27 | + |
| 28 | + es: { |
| 29 | + translation: { |
| 30 | + info: "Nuestros proyectos", |
| 31 | + baseline: "Desarrollo de software y scripts", |
| 32 | + discord: "Únete a nuestro Discord", |
| 33 | + devby: "Desarrollado por", |
| 34 | + }, |
| 35 | + }, |
35 | 36 | }, |
36 | 37 | fallbackLng: "en", |
37 | 38 | debug: true, |
|
40 | 41 | }, |
41 | 42 | }); |
42 | 43 |
|
| 44 | +function fillTranslations(cardsData) { |
| 45 | + console.log("loading translations..."); |
| 46 | + cardsData.forEach((card) => { |
| 47 | + card.translations.forEach((translation) => { |
| 48 | + const { lang, description } = translation; |
| 49 | + i18n.addResourceBundle( |
| 50 | + lang, |
| 51 | + "app.card", |
| 52 | + { |
| 53 | + [card.project]: { |
| 54 | + description, |
| 55 | + }, |
| 56 | + }, |
| 57 | + true, |
| 58 | + true, |
| 59 | + ); |
| 60 | + }); |
| 61 | + }); |
| 62 | +} |
| 63 | + |
| 64 | +fillTranslations(cardsData); |
| 65 | + |
| 66 | +console.log(i18n.getResourceBundle("en", "app.card")); |
| 67 | + |
43 | 68 | export default i18n; |
0 commit comments