diff --git a/package.json b/package.json
index 6ee95c5..7f8cffe 100644
--- a/package.json
+++ b/package.json
@@ -11,12 +11,14 @@
"@testing-library/react": "^10.2.1",
"@testing-library/user-event": "^12.0.2",
"axios": "^0.21.1",
+ "country-flag-icons": "^1.4.0",
"dotenv": "^10.0.0",
"framer-motion": "^4",
+ "i18next": "^20.3.5",
"js-cookie": "^2.2.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
- "react-icons": "^3.0.0",
+ "react-i18next": "^11.11.4",
"react-qr-reader": "^2.2.1",
"react-redux": "^7.2.4",
"react-router-dom": "^5.2.0",
diff --git a/src/app/store.js b/src/app/store.js
index 0220126..1a4b3cd 100644
--- a/src/app/store.js
+++ b/src/app/store.js
@@ -1,10 +1,12 @@
import { configureStore } from '@reduxjs/toolkit';
import authSlice from '../features/auth/authSlice';
import covidSlice from '../features/auth/covidSlice';
+import langSlice from '../features/auth/langSlice';
export const store = configureStore({
reducer: {
auth: authSlice,
covid: covidSlice,
+ lang: langSlice,
},
});
diff --git a/src/components/LanguageSwitcher.js b/src/components/LanguageSwitcher.js
new file mode 100644
index 0000000..bf20fd9
--- /dev/null
+++ b/src/components/LanguageSwitcher.js
@@ -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 ;
+ case 'ms':
+ return ;
+ case 'zh':
+ return ;
+ case 'ta':
+ return ;
+ default:
+ return ;
+ }
+ })();
+
+ const handleSelectLanguage = e => {
+ const languageKey = e.target.value;
+ i18n.changeLanguage(languageKey);
+ dispatch(setLanguage(languageKey));
+ };
+ return (
+
+ );
+}
+
+export default LanguageSwitcher;
diff --git a/src/features/auth/langSlice.js b/src/features/auth/langSlice.js
new file mode 100644
index 0000000..a164ca1
--- /dev/null
+++ b/src/features/auth/langSlice.js
@@ -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;
diff --git a/src/i18n.js b/src/i18n.js
new file mode 100644
index 0000000..588bd88
--- /dev/null
+++ b/src/i18n.js
@@ -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;
diff --git a/src/index.js b/src/index.js
index 96b7d62..bcf46b0 100644
--- a/src/index.js
+++ b/src/index.js
@@ -6,6 +6,7 @@ import App from './App';
import { store } from './app/store';
import reportWebVitals from './reportWebVitals';
import * as serviceWorker from './serviceWorker';
+import './i18n';
import { Provider } from 'react-redux';
require('dotenv').config();
diff --git a/src/locales/en/common.json b/src/locales/en/common.json
new file mode 100644
index 0000000..e1443d1
--- /dev/null
+++ b/src/locales/en/common.json
@@ -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> 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.
All the code for this project is <8>Open Source8>, 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>POSITIVE1> 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.
<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?"
+}
diff --git a/src/locales/ms/common.json b/src/locales/ms/common.json
new file mode 100644
index 0000000..7b015f4
--- /dev/null
+++ b/src/locales/ms/common.json
@@ -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> 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.
Segala kod untuk projek ini ialah <8>Sumber Terbuka8>, 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>POSITIF1> COVID19. Lockout ini adalah untuk mengingatkan anda supaya mengkuarantinkan diri mengikut polisi kesihatan COVID19 tempatan. Lockout ini akan dibatalkan selepas 14 hari.
<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."
+}
diff --git a/src/locales/ta/common.json b/src/locales/ta/common.json
new file mode 100644
index 0000000..e1443d1
--- /dev/null
+++ b/src/locales/ta/common.json
@@ -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> 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.
All the code for this project is <8>Open Source8>, 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>POSITIVE1> 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.
<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?"
+}
diff --git a/src/locales/zh/common.json b/src/locales/zh/common.json
new file mode 100644
index 0000000..e1443d1
--- /dev/null
+++ b/src/locales/zh/common.json
@@ -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> 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.
All the code for this project is <8>Open Source8>, 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>POSITIVE1> 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.
<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?"
+}
diff --git a/src/screens/HomeScreen.js b/src/screens/HomeScreen.js
index adf47d5..0c1abd0 100644
--- a/src/screens/HomeScreen.js
+++ b/src/screens/HomeScreen.js
@@ -16,8 +16,10 @@ import {
} from '@chakra-ui/react';
import axios from 'axios';
import { Fragment, React, useEffect, useRef, useState } from 'react';
+import { useTranslation } from 'react-i18next';
import { useDispatch, useSelector } from 'react-redux';
import { Redirect, useHistory } from 'react-router-dom';
+import LanguageSwitcher from '../components/LanguageSwitcher';
import { authLogout } from '../features/auth/authSlice';
import { setCovidPositive } from '../features/auth/covidSlice';
@@ -54,13 +56,14 @@ function ConfirmCOVIDPositiveAlertDialog() {
const toast = useToast();
const history = useHistory();
const dispatch = useDispatch();
+ const [t] = useTranslation();
const onClose = () => {
setOpen(false);
};
- const showErrorToast = (errorMessage = 'An error has occured.') => {
+ const showErrorToast = (errorMessage = t('defaultErrorToastDescription')) => {
toast.closeAll();
toast({
- title: 'Error!',
+ title: t('errorToastTitle'),
description: errorMessage,
status: 'error',
duration: 5000,
@@ -68,8 +71,8 @@ function ConfirmCOVIDPositiveAlertDialog() {
};
const onConfirm = () => {
toast({
- title: 'Confirming',
- description: 'Hold on while we confirm with our servers.',
+ title: t('confirmingToastTitle'),
+ description: t('confirmingToastDescription'),
status: 'info',
duration: 10000,
});
@@ -86,7 +89,7 @@ function ConfirmCOVIDPositiveAlertDialog() {
dispatch(setCovidPositive());
toast.closeAll();
toast({
- title: 'Confirmed!',
+ title: t('confirmedToastTitle'),
status: 'info',
duration: 2000,
});
@@ -98,7 +101,7 @@ function ConfirmCOVIDPositiveAlertDialog() {
console.log(err);
try {
if (err.response.status === 401) {
- showErrorToast('You are not logged in!');
+ showErrorToast(t('notLoggedInToastDescription'));
history.push('/login');
} else {
showErrorToast();
@@ -120,7 +123,7 @@ function ConfirmCOVIDPositiveAlertDialog() {
setOpen(true);
}}
>
- Report Positive COVID19
+ {t('covidPositiveReportButton')}
- Confirm Tested COVID19 Positive
+ {t('covidPositiveAlertHeader')}
-
- 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.
-
+ {t('covidPositiveAlertBody')}
@@ -155,6 +154,7 @@ function ConfirmCOVIDPositiveAlertDialog() {
function Home() {
const history = useHistory();
const dispatch = useDispatch();
+ const [t] = useTranslation();
const handleLogout = () => {
dispatch(authLogout());
@@ -198,8 +198,7 @@ function Home() {
>
- This is your QR code. Show this to others to allow them to confirm a
- contact, or allow them to create an account!
+ {t('homeExplanation')}
{process.env.REACT_APP_DONATE_LINK && (
-
- 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!
-
+ {t('donateButtonParagraph')}
)}
+
+
);
diff --git a/src/screens/LockoutScreen.js b/src/screens/LockoutScreen.js
index 82bd469..1cbbf93 100644
--- a/src/screens/LockoutScreen.js
+++ b/src/screens/LockoutScreen.js
@@ -1,6 +1,7 @@
import { Flex, Heading, Text, useToast } from '@chakra-ui/react';
import axios from 'axios';
import { useEffect } from 'react';
+import { Trans, useTranslation } from 'react-i18next';
import { useDispatch, useSelector } from 'react-redux';
import { Redirect, useHistory } from 'react-router-dom';
import { authLogout } from '../features/auth/authSlice';
@@ -15,10 +16,11 @@ function Lockout() {
const dispatch = useDispatch();
const history = useHistory();
const toast = useToast();
+ const [t] = useTranslation();
useEffect(() => {
toast({
- title: 'Checking your lockout status...',
+ title: t('checkingLockoutToastTitle'),
status: 'info',
duration: 10000,
});
@@ -44,14 +46,14 @@ function Lockout() {
history.push('/login');
} else {
toast({
- title: 'Server Error Occurred',
+ title: t('defaultErrorToastDescription'),
status: 'error',
duration: 10000,
});
}
} catch (e) {}
});
- }, [dispatch, history, toast]);
+ }, [dispatch, history, toast, t]);
if (!isAuthenticated) return ;
if (!isCovidPositive) return ;
@@ -72,19 +74,21 @@ function Lockout() {
rounded={6}
id="contentFlex"
>
- Lockout
-
- You have reported that you have been tested POSITIVE 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.
-
-
-
- Please avoid contact with other people for the duration of this
- lockout!
-
-
+ {t('Lockout')}
+
+
+ You have reported that you have been tested POSITIVE 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.
+
+
+
+ Please avoid contact with other people for the duration of this
+ lockout!
+
+
+
);
diff --git a/src/screens/LoginScreen.js b/src/screens/LoginScreen.js
index 56d5f50..c6926ee 100644
--- a/src/screens/LoginScreen.js
+++ b/src/screens/LoginScreen.js
@@ -1,23 +1,27 @@
import { Divider, Flex, Heading, Link, Text, useToast } from '@chakra-ui/react';
import axios from 'axios';
import { React } from 'react';
+import { useTranslation } from 'react-i18next';
+import { Trans } from 'react-i18next';
import { useDispatch, useSelector } from 'react-redux';
import { Redirect, useHistory } from 'react-router-dom';
import TelegramLoginButton from 'react-telegram-login';
+import LanguageSwitcher from '../components/LanguageSwitcher';
import { authLogin, authLogout } from '../features/auth/authSlice';
function Login() {
const toast = useToast();
const history = useHistory();
const dispatch = useDispatch();
+ const [t] = useTranslation();
const isAuthenticated = useSelector(state => state.auth.isAuthenticated);
if (isAuthenticated) return ;
const handleTelegramResponse = response => {
toast({
- title: 'Logging you in',
- description: "Hold on, we're logging you in.",
+ title: t('loggingInToastTitle'),
+ description: t('loggingInToastDescription'),
status: 'info',
duration: 10000,
isClosable: false,
@@ -45,7 +49,7 @@ function Login() {
toast.closeAll();
dispatch(authLogout());
toast({
- title: 'An error occurred',
+ title: t('defaultErrorToastDescription'),
description: response.data.message,
status: 'error',
duration: 9000,
@@ -59,8 +63,8 @@ function Login() {
if (err.response.status === 401) {
dispatch(authLogout());
toast({
- title: 'Login Failed',
- description: 'The wrong credentials were used.',
+ title: t('failedLoginToastTitle'),
+ description: t('failedLoginToastDescription'),
status: 'error',
duration: 9000,
isClosable: true,
@@ -68,8 +72,8 @@ function Login() {
}
} else {
toast({
- title: 'An error occurred',
- description: 'Sorry, an error occurred on our side.',
+ title: t('errorToastTitle'),
+ description: t('defaultErrorToastDescription'),
status: 'error',
duration: 9000,
isClosable: true,
@@ -95,36 +99,40 @@ function Login() {
id="contentFlex"
>
- OurSejahtera Contact Tracing
+ {t('appTitle')}
- Login
+ {t('login')}
-
- Privacy notes:
- 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.
-
-
- All the code for this project is{' '}
-
- Open Source
-
- , that means anyone, including you can audit and verify that your
- information is being handled securely.
-
+
+
+ Privacy notes:
+ 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.
+
+
+ All the code for this project is{' '}
+
+ Open Source
+
+ , that means anyone, including you can audit and verify that your
+ information is being handled securely.
+
+
+
+
);
diff --git a/src/screens/ScannerScreen.js b/src/screens/ScannerScreen.js
index 213d3b6..0d4a47b 100644
--- a/src/screens/ScannerScreen.js
+++ b/src/screens/ScannerScreen.js
@@ -1,6 +1,7 @@
import { Button, Divider, Flex, useToast } from '@chakra-ui/react';
import axios from 'axios';
import { useEffect, useState } from 'react';
+import { useTranslation } from 'react-i18next';
import QrReader from 'react-qr-reader';
import { useDispatch, useSelector } from 'react-redux';
import { Redirect, useHistory } from 'react-router-dom';
@@ -11,6 +12,7 @@ function Scanner() {
const toast = useToast();
const history = useHistory();
const dispatch = useDispatch();
+ const [t] = useTranslation();
const [scanData, setScanData] = useState(null);
@@ -32,8 +34,7 @@ function Scanner() {
const hash = re.exec(scanData);
if (hash) {
toast({
- title: 'Checking QR code.',
- description: "Hold on, we're checking this QR code.",
+ title: t('checkingQRToastTitle'),
status: 'info',
duration: 10000,
isClosable: false,
@@ -51,14 +52,13 @@ function Scanner() {
if (res.data.loggedIn) {
toast.closeAll();
toast({
- title: 'Contact Succesfully Logged',
+ title: t('contactLoggedToastTitle'),
status: 'info',
duration: 2000,
});
} else {
toast({
- title: "You're not logged in!",
- description: 'Please log in and try again!',
+ title: t('notLoggedInToastDescription'),
status: 'error',
duration: 2000,
});
@@ -70,7 +70,7 @@ function Scanner() {
.catch(e => {
toast.closeAll();
toast({
- title: 'Bad Verification',
+ title: t('badVerificationToastTitle'),
status: 'error',
duration: 2000,
});
@@ -78,14 +78,14 @@ function Scanner() {
} else {
toast.closeAll();
toast({
- title: 'Bad QR code',
+ title: t('badQRCodeToastTitle'),
status: 'error',
duration: 3000,
isClosable: true,
});
}
}
- }, [scanData, dispatch, history, toast]);
+ }, [scanData, dispatch, history, toast, t]);
const isAuthenticated = useSelector(state => state.auth.isAuthenticated);
const isCovidPositive = useSelector(state => state.covid.isCovidPositive);
@@ -135,7 +135,7 @@ function Scanner() {
history.push('/home');
}}
>
- Show my QR Code
+ {t('showQRCode')}
diff --git a/src/screens/SuccessScreen.js b/src/screens/SuccessScreen.js
index ec2fa94..58d0df9 100644
--- a/src/screens/SuccessScreen.js
+++ b/src/screens/SuccessScreen.js
@@ -1,8 +1,10 @@
import { Button, Flex, Heading, Text } from '@chakra-ui/react';
+import { useTranslation } from 'react-i18next';
import { useHistory } from 'react-router-dom';
function Success() {
const history = useHistory();
+ const [t] = useTranslation();
return (
Success!
-
- We have succesfully saved your contact! Stay safe out there, and let
- others scan your QR code too!
-
+ {t('contactSavedParagraph')}
diff --git a/src/screens/VerifyScreen.js b/src/screens/VerifyScreen.js
index aedcedf..dcec47b 100644
--- a/src/screens/VerifyScreen.js
+++ b/src/screens/VerifyScreen.js
@@ -1,12 +1,14 @@
import { Flex, Text } from '@chakra-ui/react';
import axios from 'axios';
import { useEffect, useState } from 'react';
+import { useTranslation } from 'react-i18next';
import { useHistory } from 'react-router-dom';
function Verify(props) {
const verifyID = props.match.params.id;
const [verifyError, setVerifyError] = useState(false);
const history = useHistory();
+ const [t] = useTranslation();
useEffect(() => {
if (verifyError) return;
@@ -32,14 +34,8 @@ function Verify(props) {
});
}, [verifyError, history, verifyID]);
- const errorMessage = (
-
- An error has occured verifying you. Please try scanning the QR code again?
-
- );
- const loadingMessage = (
- We are currently verifying you. Please wait.
- );
+ const errorMessage = {t('verifyingErrorParagraph')};
+ const loadingMessage = {t('verifyingParagraph')};
return (