mirror of
https://github.com/UiO-Gaming/uiogaming.no.git
synced 2026-11-05 13:56:47 +01:00
I should've divided this into multiple commits but oh well. This is just initial as there are still parts that needs to be done. Particularly user generated content needs to be translated somehow. See issue #45 for more info
43 lines
970 B
JavaScript
43 lines
970 B
JavaScript
import * as React from "react"
|
|
import * as styles from "./languageSelector.module.css"
|
|
|
|
import { NO, GB } from "country-flag-icons/react/3x2"
|
|
import { useTranslation, useI18next } from "gatsby-plugin-react-i18next"
|
|
|
|
const LanguageSelector = () => {
|
|
const { languages, changeLanguage } = useI18next()
|
|
const { t, i18n } = useTranslation()
|
|
|
|
if (i18n.language === "no") {
|
|
return (
|
|
<a
|
|
className={styles.button}
|
|
href="#"
|
|
onClick={e => {
|
|
e.preventDefault()
|
|
changeLanguage("en")
|
|
}}
|
|
>
|
|
<GB className={styles.flag} title={t("altText.flag")} />
|
|
English
|
|
</a>
|
|
)
|
|
} else {
|
|
return (
|
|
<a
|
|
className={styles.button}
|
|
href="#"
|
|
onClick={e => {
|
|
e.preventDefault()
|
|
changeLanguage("no")
|
|
}}
|
|
>
|
|
<NO className={styles.flag} title={t("altText.flag")} />
|
|
Norsk
|
|
</a>
|
|
)
|
|
}
|
|
}
|
|
|
|
export default LanguageSelector
|