Skip to content

Commit

Permalink
Merge branch 'main' of github.com:CyberAula/cyberaula.github.io
Browse files Browse the repository at this point in the history
  • Loading branch information
clara7227 committed May 21, 2024
2 parents 5bef906 + d45cf94 commit 7bf8bd6
Show file tree
Hide file tree
Showing 9 changed files with 3,304 additions and 238 deletions.
32 changes: 32 additions & 0 deletions app/i18n.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import i18n from 'i18next';
import { initReactI18next } from 'react-i18next';
import LanguageDetector from 'i18next-browser-languagedetector';
import { en } from '../constants/langs/en';
import { es } from '../constants/langs/es';

i18n
// detect user language
// learn more: https://github.com/i18next/i18next-browser-languageDetector
.use(LanguageDetector)
// pass the i18n instance to react-i18next.
.use(initReactI18next)
// init i18next
// for all options read: https://www.i18next.com/overview/configuration-options
.init({
debug: true,
fallbackLng: 'en',
interpolation: {
escapeValue: false, // not needed for react as it escapes by default
},
resources: {}});

i18n.addResourceBundle('en', 'translation', {
...en
});
i18n.addResourceBundle('es', 'translation', {
...es
});



export default i18n;
3 changes: 3 additions & 0 deletions app/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import './sass/main.scss';
import "./globals.sass";
// import 'bootstrap/dist/css/bootstrap.min.css';

// import i18n (needs to be bundled ;))
import './i18n';

const montserrat = Montserrat({ subsets: ["latin"] });

export default function RootLayout({ children }) {
Expand Down
8 changes: 6 additions & 2 deletions app/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@ import BulletElement from "@/components/BulletElement";
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faAward } from '@fortawesome/free-solid-svg-icons';

import { useTranslation } from 'react-i18next';


export default function Home() {
const [carousel, setCarousel] = useState(mycarousel);
const { t } = useTranslation();


useEffect(() => {
window.scrollTo(0, 0);
Expand All @@ -28,8 +33,7 @@ export default function Home() {
<div className="head">
<div className="group_description">
<h1>
<b>Bienvenido a cyberaula, </b>la iniciativa de innovación
educativa de la UPM.
<b>{t('front.title')}, </b>{t('front.title2')}
</h1>
</div>
</div>
Expand Down
4 changes: 4 additions & 0 deletions components/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useState, useEffect } from "react";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faBars } from "@fortawesome/free-solid-svg-icons";
import { faXmark } from "@fortawesome/free-solid-svg-icons";
import LangSwitcher from "./LangSwitcher";

const routes = [
//{route: "/", title: "Home"},
Expand Down Expand Up @@ -33,6 +34,9 @@ export default function Header(props) {
</div>
</div>
</a>

<LangSwitcher />

<div className="menu_icon">
<i
className={
Expand Down
28 changes: 28 additions & 0 deletions components/LangSwitcher.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { useTranslation } from 'react-i18next';


const lngs = {
en: { nativeName: 'English' },
es: { nativeName: 'Spanish' }
};


export default function LangSwitcher() {
const { i18n } = useTranslation();
return (
<div>
{Object.keys(lngs).map((lng) => (
<button
key={lng}
style={{
fontWeight: i18n.language === lng ? 'bold' : 'normal',
}}
type="submit"
onClick={() => i18n.changeLanguage(lng)}
>
{lngs[lng].nativeName}
</button>
))}
</div>
);
}
15 changes: 15 additions & 0 deletions constants/langs/en.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export const en = {
"header": {
"publicationstab": "Publications"
},
"front": {
"title": "Welcome to CyberAula",
"title2": "innovation group of the UPM"
},
"publications": {
"title": "Publications"
},
"cursos": {
"title": "Courses"
}
}
15 changes: 15 additions & 0 deletions constants/langs/es.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export const es = {
"header": {
"publicationstab": "Publicaciones"
},
"front": {
"title": "Bienvenido a CyberAula",
"title2": "grupo de innovación educativa de la UPM"
},
"publications": {
"title": "Publicaciones"
},
"cursos": {
"title": "Cursos"
}
}
Loading

0 comments on commit 7bf8bd6

Please sign in to comment.