Files
uiogaming.no/src/components/items/languageSelector.js
T
LBlend aec4a9406e initial translation support
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
2024-03-13 02:36:31 +01:00

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