import {useTranslation} from '../hooks/';
const {t, locale, setLocale} = useTranslation();
const isEN = locale.includes('en');
<Switch
checked={!isEN}
onPress={(checked) => setLocale(checked ? 'kr' : 'en')}
/>
<Text> {t('screens.client')} </Text>
import * as en from './en.json'
import * as fr from './fr.json'
import * as kr from './kr.json'
export default {
en,
fr,
kr
}
en.json
{
"navigation": {
"home": "Cargo4U Home",
"tracking": "My tracking Status",
"profile": "Edit My Profile",
"logout": "Logout"
}
}
kr.json
{
"navigation": {
"home": "카고4U 홈",
"tracking": "내 예약 확인",
"profile": "프로필 수정하기",
"logout": "로그아웃"
}
}
useTranslation.tsx
const [locale, setLocale] = useState('kr');