Browse Source
add internationalization currently only malay language supported. skeleton for tamil and chinese is setup.development
Nareshkumar Rao
3 years ago
committed by
GitHub
17 changed files with 430 additions and 100 deletions
@ -1,10 +1,12 @@ |
|||||
import { configureStore } from '@reduxjs/toolkit'; |
import { configureStore } from '@reduxjs/toolkit'; |
||||
import authSlice from '../features/auth/authSlice'; |
import authSlice from '../features/auth/authSlice'; |
||||
import covidSlice from '../features/auth/covidSlice'; |
import covidSlice from '../features/auth/covidSlice'; |
||||
|
import langSlice from '../features/auth/langSlice'; |
||||
|
|
||||
export const store = configureStore({ |
export const store = configureStore({ |
||||
reducer: { |
reducer: { |
||||
auth: authSlice, |
auth: authSlice, |
||||
covid: covidSlice, |
covid: covidSlice, |
||||
|
lang: langSlice, |
||||
}, |
}, |
||||
}); |
}); |
||||
|
@ -0,0 +1,46 @@ |
|||||
|
import { Select } from '@chakra-ui/react'; |
||||
|
import Flags from 'country-flag-icons/react/3x2'; |
||||
|
import { useTranslation } from 'react-i18next'; |
||||
|
import { useDispatch } from 'react-redux'; |
||||
|
import { setLanguage } from '../features/auth/langSlice'; |
||||
|
|
||||
|
function LanguageSwitcher() { |
||||
|
const [, i18n] = useTranslation(); |
||||
|
const dispatch = useDispatch(); |
||||
|
|
||||
|
const currentLangIcon = (() => { |
||||
|
switch (i18n.language) { |
||||
|
case 'en': |
||||
|
return <Flags.GB />; |
||||
|
case 'ms': |
||||
|
return <Flags.MY />; |
||||
|
case 'zh': |
||||
|
return <Flags.CN />; |
||||
|
case 'ta': |
||||
|
return <Flags.IN />; |
||||
|
default: |
||||
|
return <Flags.GB />; |
||||
|
} |
||||
|
})(); |
||||
|
|
||||
|
const handleSelectLanguage = e => { |
||||
|
const languageKey = e.target.value; |
||||
|
i18n.changeLanguage(languageKey); |
||||
|
dispatch(setLanguage(languageKey)); |
||||
|
}; |
||||
|
return ( |
||||
|
<Select |
||||
|
value={i18n.language} |
||||
|
icon={currentLangIcon} |
||||
|
variant="filled" |
||||
|
onChange={handleSelectLanguage} |
||||
|
> |
||||
|
<option value="en">English</option> |
||||
|
<option value="ms">Bahasa Melayu</option> |
||||
|
{/*<option value="zh">中文</option> |
||||
|
<option value="ta">தமிழ்</option>*/} |
||||
|
</Select> |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
export default LanguageSwitcher; |
@ -0,0 +1,21 @@ |
|||||
|
import { createSlice } from '@reduxjs/toolkit'; |
||||
|
import Cookies from 'js-cookie'; |
||||
|
|
||||
|
const initialState = { |
||||
|
lang: Cookies.get('lang'), |
||||
|
}; |
||||
|
|
||||
|
export const langSlice = createSlice({ |
||||
|
name: 'lang', |
||||
|
initialState, |
||||
|
reducers: { |
||||
|
setLanguage: (state, action) => { |
||||
|
state.lang = action.payload; |
||||
|
Cookies.set('lang', action.payload); |
||||
|
}, |
||||
|
}, |
||||
|
}); |
||||
|
|
||||
|
export const { setLanguage } = langSlice.actions; |
||||
|
|
||||
|
export default langSlice.reducer; |
@ -0,0 +1,34 @@ |
|||||
|
import i18n from 'i18next'; |
||||
|
import Cookies from 'js-cookie'; |
||||
|
import { initReactI18next } from 'react-i18next'; |
||||
|
import enTranslation from './locales/en/common.json'; |
||||
|
import msTranslation from './locales/ms/common.json'; |
||||
|
import taTranslation from './locales/ta/common.json'; |
||||
|
import zhTranslation from './locales/zh/common.json'; |
||||
|
|
||||
|
const resources = { |
||||
|
en: { |
||||
|
common: enTranslation, |
||||
|
}, |
||||
|
ms: { |
||||
|
common: msTranslation, |
||||
|
}, |
||||
|
zh: { |
||||
|
common: zhTranslation, |
||||
|
}, |
||||
|
ta: { |
||||
|
common: taTranslation, |
||||
|
}, |
||||
|
}; |
||||
|
|
||||
|
i18n.use(initReactI18next).init({ |
||||
|
resources, |
||||
|
lng: Cookies.get('lang') ? Cookies.get('lang') : 'en', |
||||
|
defaultNS: 'common', |
||||
|
interpolation: { |
||||
|
escapeValue: false, |
||||
|
}, |
||||
|
debug: true, |
||||
|
}); |
||||
|
|
||||
|
export default i18n; |
@ -0,0 +1,49 @@ |
|||||
|
{ |
||||
|
"appTitle": "OurSejahtera Contact Tracing", |
||||
|
|
||||
|
"homeExplanation": "This is your QR code. Show this to others to allow them to confirm a contact, or allow them to create an account!", |
||||
|
"scanButtonLabel": "Scan a QR Code", |
||||
|
|
||||
|
"donateButtonLabel": "Donate!", |
||||
|
"donateButtonParagraph": "Servers require money to run, and apps require labor to develop and maintain. You can show your support by donating what you can. Every cent counts, buy me my next coffee, or help pay for a month of server usage!", |
||||
|
|
||||
|
"logOutButtonLabel": "Log Out!", |
||||
|
|
||||
|
"covidPositiveReportButton": "Report Positive COVID19", |
||||
|
"covidPositiveAlertHeader": "Confirm Tested COVID19 Positive", |
||||
|
"covidPositiveAlertBody": "Please confirm that you have been tested POSITIVE with COVID19. Upon confirmation, this app will inform the people you have come in contact with in the last 7 days.", |
||||
|
|
||||
|
"confirm": "Confirm", |
||||
|
"cancel": "Cancel", |
||||
|
|
||||
|
"errorToastTitle": "Error!", |
||||
|
"defaultErrorToastDescription": "An error has occured.", |
||||
|
"confirmedToastTitle": "Confirmed!", |
||||
|
"confirmingToastTitle": "Confirming", |
||||
|
"confirmingToastDescription": "Hold on while we confirm with our servers.", |
||||
|
"notLoggedInToastDescription": "You are not logged in!", |
||||
|
"failedLoginToastTitle": "Login Failed", |
||||
|
"failedLoginToastDescription": "The wrong credentials were used", |
||||
|
"loggingInToastTitle": "Logging you in", |
||||
|
"loggingInToastDescription": "Hold on, we're logging you in.", |
||||
|
"checkingLockoutToastTitle": "Checking your lockout status...", |
||||
|
"badVerificationToastTitle": "Bad Verification", |
||||
|
"badQRCodeToastTitle": "Bad QR Code", |
||||
|
"contactLoggedToastTitle": "Contact Successfully Logged", |
||||
|
"checkingQRToastTitle": "Hold on, we're checking this QR code.", |
||||
|
|
||||
|
"login": "Login", |
||||
|
|
||||
|
"loginPrivacyNotice": "<0><0>Privacy notes:</0> <br/>Telegram Login allows us to verify your identity, without collecting any of your data. Telegram does NOT give us your phone number. The only piece of information stored on our server is your Telegram ID, this is an internal ID Number Telegram uses that is SEPARATE from your Telegram Username.<br/><br/>All the code for this project is <8>Open Source</8>, that means anyone, including you can audit and verify that your information is being handled securely.</0>", |
||||
|
|
||||
|
"lockout": "Lockout", |
||||
|
"lockoutExplanation": "<0>You have reported that you have been tested <1>POSITIVE</1> with COVID19. This lockout is to remind you to quarantine yourself according to local COVID19 health policies. This lockout will automatically be lifted after 14 days.<br/><br/><5>Please avoid contact with other people for the duration of this lockout!</5></0>", |
||||
|
|
||||
|
"showQRCode": "Show my QR Code", |
||||
|
|
||||
|
"contactSavedParagraph": "We have succesfully saved your contact! Stay safe out there, and let others scan your QR code too!", |
||||
|
"returnHomeButtonLabel": "Return home", |
||||
|
|
||||
|
"verifyingParagraph": "We are currently verifying you. Please wait.", |
||||
|
"verifyingErrorParagraph": "An error has occured verifying you. Please try scanning the QR code again?" |
||||
|
} |
@ -0,0 +1,49 @@ |
|||||
|
{ |
||||
|
"appTitle": "Pengesanan Kontak OurSejahtera", |
||||
|
|
||||
|
"homeExplanation": "Ini ialah kod QR anda. Tunjukkan kepada pengguna lain untuk mengesahkan kenalan.", |
||||
|
"scanButtonLabel": "Imbas kod QR", |
||||
|
|
||||
|
"donateButtonLabel": "Derma!", |
||||
|
"donateButtonParagraph": "Memelihara server memerlukan wang dan membuat serta memantau aplikasi memerlukan tenaga kerja. Anda boleh menghulurkan bantuan dengan menderma mengikut kemampuan. Setiap sen ada nilainya.", |
||||
|
|
||||
|
"logOutButtonLabel": "Daftar Keluar!", |
||||
|
|
||||
|
"covidPositiveReportButton": "Laporkan Positif COVID19", |
||||
|
"covidPositiveAlertHeader": "Sahkan Diuji Positif COVID19", |
||||
|
"covidPositiveAlertBody": "Sila sahkan bahawa anda telah diuji positif COVID19. Atas pengesahan, aplikasi ini akan memaklumkan para individu yang telah bersemuka dengan anda dalam 7 hari yang lepas.", |
||||
|
|
||||
|
"confirm": "Sahkan", |
||||
|
"cancel": "Batalkan", |
||||
|
|
||||
|
"errorToastTitle": "Ralat!", |
||||
|
"defaultErrorToastDescription": "Ralat Berlaku.", |
||||
|
"confirmedToastTitle": "Disahkan!", |
||||
|
"confirmingToastTitle": "Mengesahkan", |
||||
|
"confirmingToastDescription": "Sila tunggu sebentar sementara kami sedang mengesahkan dengan server kami.", |
||||
|
"notLoggedInToastDescription": "Anda tidak didaftar masuk!", |
||||
|
"failedLoginToastTitle": "Gagal Daftar Masuk", |
||||
|
"failedLoginToastDescription": "Kelayakan yang salah telah digunakan", |
||||
|
"loggingInToastTitle": "Mendaftar masuk", |
||||
|
"loggingInToastDescription": "Sila tunggu sebentar sementara anda didaftar masuk.", |
||||
|
"checkingLockoutToastTitle": "Memeriksa status lockout anda...", |
||||
|
"badVerificationToastTitle": "Pengesahan Tidak Berfungsi", |
||||
|
"badQRCodeToastTitle": "Kod QR Tidak Berfungsi", |
||||
|
"contactLoggedToastTitle": "Kontak Berjaya Didaftar", |
||||
|
"checkingQRToastTitle": "Sila tunggu sebentar. Kami sedang memeriksa kod QR ini.", |
||||
|
|
||||
|
"login": "Daftar Masuk", |
||||
|
|
||||
|
"loginPrivacyNotice": "<0><0>Notis Privasi:</0> <br/>Pendaftaran masuk melalui Telegram membolehkan pengesahan identiti anda tanpa pengumpulan data peribadi anda. Telegram TIDAK mendedahkan nombor telefon anda. Hanya ID Telegram anda akan disimpan dalam server kami. Ini ialah Nombor ID Telegram dalaman yang digunakan oleh Telegram dan BUKANNYA nama pengguna Telegram anda.<br/><br/>Segala kod untuk projek ini ialah <8>Sumber Terbuka</8>, bermaksud sesiapa sahaja, termasuk diri anda boleh mengaudit dan mengesahkan bahawa segala maklumat dikendalikan dengan selamat.</0>", |
||||
|
|
||||
|
"lockout": "Lockout", |
||||
|
"lockoutExplanation": "<0>Anda telah laporkan bahawa anda diuji <1>POSITIF</1> COVID19. Lockout ini adalah untuk mengingatkan anda supaya mengkuarantinkan diri mengikut polisi kesihatan COVID19 tempatan. Lockout ini akan dibatalkan selepas 14 hari.<br/><br/><5>Anda diminta untuk elak daripada berinteraksi dengan orang lain sewaktu lockout ini.</5></0>", |
||||
|
|
||||
|
"showQRCode": "Tunjuk kod QR saya", |
||||
|
|
||||
|
"contactSavedParagraph": "Kontak anda berjaya disimpan! Jaga kesejahteraan diri dan berikan orang lain imbas kod QR anda juga!", |
||||
|
"returnHomeButtonLabel": "Kembali", |
||||
|
|
||||
|
"verifyingParagraph": "Kami sedang mengesahkan anda. Sila tunggu sebentar.", |
||||
|
"verifyingErrorParagraph": "Ralat berlaku sewaktu pengesahan. Sila imbas kod QR sekali lagi." |
||||
|
} |
@ -0,0 +1,49 @@ |
|||||
|
{ |
||||
|
"appTitle": "OurSejahtera Contact Tracing", |
||||
|
|
||||
|
"homeExplanation": "This is your QR code. Show this to others to allow them to confirm a contact, or allow them to create an account!", |
||||
|
"scanButtonLabel": "Scan a QR Code", |
||||
|
|
||||
|
"donateButtonLabel": "Donate!", |
||||
|
"donateButtonParagraph": "Servers require money to run, and apps require labor to develop and maintain. You can show your support by donating what you can. Every cent counts, buy me my next coffee, or help pay for a month of server usage!", |
||||
|
|
||||
|
"logOutButtonLabel": "Log Out!", |
||||
|
|
||||
|
"covidPositiveReportButton": "Report Positive COVID19", |
||||
|
"covidPositiveAlertHeader": "Confirm Tested COVID19 Positive", |
||||
|
"covidPositiveAlertBody": "Please confirm that you have been tested POSITIVE with COVID19. Upon confirmation, this app will inform the people you have come in contact with in the last 7 days.", |
||||
|
|
||||
|
"confirm": "Confirm", |
||||
|
"cancel": "Cancel", |
||||
|
|
||||
|
"errorToastTitle": "Error!", |
||||
|
"defaultErrorToastDescription": "An error has occured.", |
||||
|
"confirmedToastTitle": "Confirmed!", |
||||
|
"confirmingToastTitle": "Confirming", |
||||
|
"confirmingToastDescription": "Hold on while we confirm with our servers.", |
||||
|
"notLoggedInToastDescription": "You are not logged in!", |
||||
|
"failedLoginToastTitle": "Login Failed", |
||||
|
"failedLoginToastDescription": "The wrong credentials were used", |
||||
|
"loggingInToastTitle": "Logging you in", |
||||
|
"loggingInToastDescription": "Hold on, we're logging you in.", |
||||
|
"checkingLockoutToastTitle": "Checking your lockout status...", |
||||
|
"badVerificationToastTitle": "Bad Verification", |
||||
|
"badQRCodeToastTitle": "Bad QR Code", |
||||
|
"contactLoggedToastTitle": "Contact Successfully Logged", |
||||
|
"checkingQRToastTitle": "Hold on, we're checking this QR code.", |
||||
|
|
||||
|
"login": "Login", |
||||
|
|
||||
|
"loginPrivacyNotice": "<0><0>Privacy notes:</0> <br/>Telegram Login allows us to verify your identity, without collecting any of your data. Telegram does NOT give us your phone number. The only piece of information stored on our server is your Telegram ID, this is an internal ID Number Telegram uses that is SEPARATE from your Telegram Username.<br/><br/>All the code for this project is <8>Open Source</8>, that means anyone, including you can audit and verify that your information is being handled securely.</0>", |
||||
|
|
||||
|
"lockout": "Lockout", |
||||
|
"lockoutExplanation": "<0>You have reported that you have been tested <1>POSITIVE</1> with COVID19. This lockout is to remind you to quarantine yourself according to local COVID19 health policies. This lockout will automatically be lifted after 14 days.<br/><br/><5>Please avoid contact with other people for the duration of this lockout!</5></0>", |
||||
|
|
||||
|
"showQRCode": "Show my QR Code", |
||||
|
|
||||
|
"contactSavedParagraph": "We have succesfully saved your contact! Stay safe out there, and let others scan your QR code too!", |
||||
|
"returnHomeButtonLabel": "Return home", |
||||
|
|
||||
|
"verifyingParagraph": "We are currently verifying you. Please wait.", |
||||
|
"verifyingErrorParagraph": "An error has occured verifying you. Please try scanning the QR code again?" |
||||
|
} |
@ -0,0 +1,49 @@ |
|||||
|
{ |
||||
|
"appTitle": "OurSejahtera Contact Tracing", |
||||
|
|
||||
|
"homeExplanation": "This is your QR code. Show this to others to allow them to confirm a contact, or allow them to create an account!", |
||||
|
"scanButtonLabel": "Scan a QR Code", |
||||
|
|
||||
|
"donateButtonLabel": "Donate!", |
||||
|
"donateButtonParagraph": "Servers require money to run, and apps require labor to develop and maintain. You can show your support by donating what you can. Every cent counts, buy me my next coffee, or help pay for a month of server usage!", |
||||
|
|
||||
|
"logOutButtonLabel": "Log Out!", |
||||
|
|
||||
|
"covidPositiveReportButton": "Report Positive COVID19", |
||||
|
"covidPositiveAlertHeader": "Confirm Tested COVID19 Positive", |
||||
|
"covidPositiveAlertBody": "Please confirm that you have been tested POSITIVE with COVID19. Upon confirmation, this app will inform the people you have come in contact with in the last 7 days.", |
||||
|
|
||||
|
"confirm": "Confirm", |
||||
|
"cancel": "Cancel", |
||||
|
|
||||
|
"errorToastTitle": "Error!", |
||||
|
"defaultErrorToastDescription": "An error has occured.", |
||||
|
"confirmedToastTitle": "Confirmed!", |
||||
|
"confirmingToastTitle": "Confirming", |
||||
|
"confirmingToastDescription": "Hold on while we confirm with our servers.", |
||||
|
"notLoggedInToastDescription": "You are not logged in!", |
||||
|
"failedLoginToastTitle": "Login Failed", |
||||
|
"failedLoginToastDescription": "The wrong credentials were used", |
||||
|
"loggingInToastTitle": "Logging you in", |
||||
|
"loggingInToastDescription": "Hold on, we're logging you in.", |
||||
|
"checkingLockoutToastTitle": "Checking your lockout status...", |
||||
|
"badVerificationToastTitle": "Bad Verification", |
||||
|
"badQRCodeToastTitle": "Bad QR Code", |
||||
|
"contactLoggedToastTitle": "Contact Successfully Logged", |
||||
|
"checkingQRToastTitle": "Hold on, we're checking this QR code.", |
||||
|
|
||||
|
"login": "Login", |
||||
|
|
||||
|
"loginPrivacyNotice": "<0><0>Privacy notes:</0> <br/>Telegram Login allows us to verify your identity, without collecting any of your data. Telegram does NOT give us your phone number. The only piece of information stored on our server is your Telegram ID, this is an internal ID Number Telegram uses that is SEPARATE from your Telegram Username.<br/><br/>All the code for this project is <8>Open Source</8>, that means anyone, including you can audit and verify that your information is being handled securely.</0>", |
||||
|
|
||||
|
"lockout": "Lockout", |
||||
|
"lockoutExplanation": "<0>You have reported that you have been tested <1>POSITIVE</1> with COVID19. This lockout is to remind you to quarantine yourself according to local COVID19 health policies. This lockout will automatically be lifted after 14 days.<br/><br/><5>Please avoid contact with other people for the duration of this lockout!</5></0>", |
||||
|
|
||||
|
"showQRCode": "Show my QR Code", |
||||
|
|
||||
|
"contactSavedParagraph": "We have succesfully saved your contact! Stay safe out there, and let others scan your QR code too!", |
||||
|
"returnHomeButtonLabel": "Return home", |
||||
|
|
||||
|
"verifyingParagraph": "We are currently verifying you. Please wait.", |
||||
|
"verifyingErrorParagraph": "An error has occured verifying you. Please try scanning the QR code again?" |
||||
|
} |
Loading…
Reference in new issue