Add i18next
parent
f9ec31fd7a
commit
ee62b85008
@ -0,0 +1,22 @@
|
||||
import React from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
|
||||
import { languages } from '../i18n'
|
||||
|
||||
export const LangSelect = () => {
|
||||
const { i18n } = useTranslation()
|
||||
return (
|
||||
<>
|
||||
<select
|
||||
value={i18n.language}
|
||||
onChange={evt => i18n.changeLanguage(evt.target.value)}
|
||||
>
|
||||
{languages.map(lng => (
|
||||
<option key={lng} value={lng}>
|
||||
{lng}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</>
|
||||
)
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
{
|
||||
"title": "Der schnelle leser",
|
||||
"search": "Suche",
|
||||
"options": {
|
||||
"title": "Optionen",
|
||||
"maxLength": "Maximale Segmentlänge",
|
||||
"wpm": "Wörter pro Minute",
|
||||
"offset": "Versatz der Wortanzeige"
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
{
|
||||
"title": "The Fast Reader",
|
||||
"search": "Search",
|
||||
"options": {
|
||||
"title": "Options",
|
||||
"maxLength": "Maximum segment length",
|
||||
"wpm": "Words per minute",
|
||||
"offset": "Offset from center"
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
import i18n from 'i18next'
|
||||
import { initReactI18next } from 'react-i18next'
|
||||
|
||||
import de from './de.json'
|
||||
import en from './en.json'
|
||||
|
||||
const resources = {
|
||||
en: { translation: en },
|
||||
de: { translation: de }
|
||||
}
|
||||
|
||||
console.log(de, en)
|
||||
i18n.use(initReactI18next).init({
|
||||
resources,
|
||||
lng: 'en',
|
||||
fallbackLng: 'en',
|
||||
interpolation: {
|
||||
escapeValue: false
|
||||
}
|
||||
})
|
||||
|
||||
export const languages = Object.keys(resources)
|
Loading…
Reference in New Issue