Add portuguese translation
This commit is contained in:
parent
effc6a4453
commit
a558bcb265
|
@ -17,6 +17,10 @@ const languages = [
|
|||
{
|
||||
label: '日本語',
|
||||
value: 'ja'
|
||||
},
|
||||
{
|
||||
label: 'Português',
|
||||
value: 'pt-PT'
|
||||
}
|
||||
]
|
||||
|
||||
|
@ -27,11 +31,16 @@ export default function Settings(props: Props) {
|
|||
useEffect(() => {
|
||||
if (typeof localStorage !== 'undefined') {
|
||||
const lang = localStorage.getItem('language')
|
||||
if (lang) {
|
||||
setLanguage(lang as localeType)
|
||||
} else {
|
||||
setLanguage('en')
|
||||
}
|
||||
}
|
||||
}, [])
|
||||
|
||||
const languageChanged = (e: string) => {
|
||||
setLanguage(e as localeType)
|
||||
if (typeof localStorage !== 'undefined') {
|
||||
localStorage.setItem('language', e)
|
||||
}
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import en from '../../locales/en/translation.json'
|
||||
import ja from '../../locales/ja/translation.json'
|
||||
import pt_pt from '../../locales/pt_pt/translation.json'
|
||||
import { flattenMessages } from '../utils/flattenMessage'
|
||||
import { createContext, useState } from 'react'
|
||||
import { IntlProvider } from 'react-intl'
|
||||
|
||||
export type localeType = 'en' | 'ja'
|
||||
export type localeType = 'en' | 'ja' | 'pt-PT'
|
||||
|
||||
type Props = {
|
||||
children: React.ReactNode
|
||||
|
@ -19,7 +20,8 @@ export const Context = createContext<Lang>({} as Lang)
|
|||
export const IntlProviderWrapper: React.FC<Props> = props => {
|
||||
const langs = [
|
||||
{ locale: 'en', messages: flattenMessages(en) },
|
||||
{ locale: 'ja', messages: flattenMessages(ja) }
|
||||
{ locale: 'ja', messages: flattenMessages(ja) },
|
||||
{ locale: 'pt-PT', messages: flattenMessages(pt_pt) }
|
||||
]
|
||||
const [lang, setLang] = useState(langs[0])
|
||||
|
||||
|
|
Loading…
Reference in New Issue