Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Commit

Permalink
fix(i18n): fix i18n translation keys and reorganize files
Browse files Browse the repository at this point in the history
fix #1668
  • Loading branch information
ocBruno committed Jan 12, 2020
1 parent 59680a0 commit dba5165
Show file tree
Hide file tree
Showing 48 changed files with 251 additions and 188 deletions.
7 changes: 0 additions & 7 deletions public/locales/actions/ar/translation.json

This file was deleted.

7 changes: 0 additions & 7 deletions public/locales/actions/de/translation.json

This file was deleted.

7 changes: 0 additions & 7 deletions public/locales/actions/en/translation.json

This file was deleted.

7 changes: 0 additions & 7 deletions public/locales/actions/es/translation.json

This file was deleted.

7 changes: 0 additions & 7 deletions public/locales/actions/in/translation.json

This file was deleted.

7 changes: 0 additions & 7 deletions public/locales/actions/ja/translation.json

This file was deleted.

7 changes: 0 additions & 7 deletions public/locales/actions/pt/translation.json

This file was deleted.

7 changes: 0 additions & 7 deletions public/locales/actions/ru/translation.json

This file was deleted.

7 changes: 0 additions & 7 deletions public/locales/actions/zr/translation.json

This file was deleted.

3 changes: 0 additions & 3 deletions public/locales/dashboard/ar/translation.json

This file was deleted.

3 changes: 0 additions & 3 deletions public/locales/dashboard/de/translation.json

This file was deleted.

3 changes: 0 additions & 3 deletions public/locales/dashboard/en/translation.json

This file was deleted.

3 changes: 0 additions & 3 deletions public/locales/dashboard/es/translation.json

This file was deleted.

3 changes: 0 additions & 3 deletions public/locales/dashboard/in/translation.json

This file was deleted.

3 changes: 0 additions & 3 deletions public/locales/dashboard/ja/translation.json

This file was deleted.

3 changes: 0 additions & 3 deletions public/locales/dashboard/pt/translation.json

This file was deleted.

3 changes: 0 additions & 3 deletions public/locales/dashboard/ru/translation.json

This file was deleted.

3 changes: 0 additions & 3 deletions public/locales/dashboard/zr/translation.json

This file was deleted.

4 changes: 0 additions & 4 deletions public/locales/patient/ar/translation.json

This file was deleted.

4 changes: 0 additions & 4 deletions public/locales/patient/de/translation.json

This file was deleted.

4 changes: 0 additions & 4 deletions public/locales/patient/en/translation.json

This file was deleted.

4 changes: 0 additions & 4 deletions public/locales/patient/es/translation.json

This file was deleted.

4 changes: 0 additions & 4 deletions public/locales/patient/in/translation.json

This file was deleted.

4 changes: 0 additions & 4 deletions public/locales/patient/ja/translation.json

This file was deleted.

4 changes: 0 additions & 4 deletions public/locales/patient/pt/translation.json

This file was deleted.

4 changes: 0 additions & 4 deletions public/locales/patient/ru/translation.json

This file was deleted.

4 changes: 0 additions & 4 deletions public/locales/patient/zr/translation.json

This file was deleted.

6 changes: 0 additions & 6 deletions public/locales/patients/ar/translation.json

This file was deleted.

6 changes: 0 additions & 6 deletions public/locales/patients/de/translation.json

This file was deleted.

6 changes: 0 additions & 6 deletions public/locales/patients/en/translation.json

This file was deleted.

6 changes: 0 additions & 6 deletions public/locales/patients/es/translation.json

This file was deleted.

6 changes: 0 additions & 6 deletions public/locales/patients/in/translation.json

This file was deleted.

6 changes: 0 additions & 6 deletions public/locales/patients/ja/translation.json

This file was deleted.

6 changes: 0 additions & 6 deletions public/locales/patients/pt/translation.json

This file was deleted.

6 changes: 0 additions & 6 deletions public/locales/patients/ru/translation.json

This file was deleted.

6 changes: 0 additions & 6 deletions public/locales/patients/zr/translation.json

This file was deleted.

6 changes: 3 additions & 3 deletions src/components/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ const Navbar = () => {
}}
navLinks={[
{
label: t('patients.label'),
label: t('patients.label', 'patients'),
onClick: () => {},
children: [
{
label: t('actions.list'),
label: t('actions.list', 'list'),
onClick: () => {
history.push('/patients')
},
},
{
label: t('actions.new'),
label: t('actions.new', 'new'),
onClick: () => {
history.push('/patients/new')
},
Expand Down
4 changes: 2 additions & 2 deletions src/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const Sidebar = () => {
<ul className="nav flex-column">
<li className="nav-item">
<Link to="/" className={`nav-link ${path.pathname === '/' ? ' active' : ''}`}>
{t('dashboard.label')}
{t('dashboard.label', 'dashboard')}
</Link>
</li>
<li className="nav-item">
Expand All @@ -21,7 +21,7 @@ const Sidebar = () => {
className={`nav-link ${path.pathname.includes('patient') ? ' active' : ''}`}
>
<Icon icon="patients" />
{` ${t('patients.label')}`}
{` ${t('patients.label', 'patients')}`}
</Link>
</li>
</ul>
Expand Down
50 changes: 47 additions & 3 deletions src/i18n.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,56 @@
import i18n from 'i18next';
import Backend from 'i18next-xhr-backend';
// import Backend from 'i18next-xhr-backend';
import LanguageDetector from 'i18next-browser-languagedetector';
import { initReactI18next } from 'react-i18next';

import translationAR from './locales/ar/translation.json';
import translationDE from './locales/de/translation.json';
import translationEN from './locales/en/translation.json';
import translationES from './locales/es/translation.json';
import translationIN from './locales/in/translation.json';
import translationJA from './locales/ja/translation.json';
import translationPT from './locales/pt/translation.json';
import translationRU from './locales/ru/translation.json';
import translationZR from './locales/zr/translation.json';

const resources = {
ar: {
translation: translationAR,
},
de: {
translation: translationDE,
},
en: {
translation: translationEN,
},
es: {
translation: translationES,
},
in: {
translation: translationIN,
},
ja: {
translation: translationJA,
},
pt: {
translation: translationPT,
},
ru: {
translation: translationRU,
},
zr: {
translation: translationZR,
},
};

i18n
// load translation using xhr -> see /public/locales
// learn more: https://github.com/i18next/i18next-xhr-backend
.use(Backend)

// SET UP Backend resource
// .use(Backend)


// detect user language
// learn more: https://github.com/i18next/i18next-browser-languageDetector
.use(LanguageDetector)
Expand All @@ -17,7 +61,7 @@ i18n
.init({
fallbackLng: 'en',
debug: true,

resources: resources,
interpolation: {
escapeValue: false, // not needed for react as it escapes by default
},
Expand Down
22 changes: 22 additions & 0 deletions src/locales/ar/translation.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"actions": {
"edit": "تصحيح",
"save": "حفظ",
"cancel": "إلغاء",
"new": "الجديد",
"list": "قائمة"
},
"dashboard": {
"label": "لوحة القيادة"
},
"patient": {
"firstName": "الاسم الاول",
"lastName": "الكنية"
},
"patients": {
"label": "المرضى",
"viewPatients": "عرض المرضى",
"viewPatient": "عرض المريض",
"newPatient": "مريض جديد"
}
}
22 changes: 22 additions & 0 deletions src/locales/de/translation.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"actions": {
"edit": "Bearbeiten",
"save": "speichern",
"cancel": "Stornieren",
"new": "Neu",
"list": "Liste"
},
"dashboard": {
"label": "لوحة القيادة"
},
"patient": {
"firstName": "Vorname",
"lastName": "Nachname"
},
"patients": {
"label": "Patienten",
"viewPatients": "Patienten anzeigen",
"viewPatient": "Patient anzeigen",
"newPatient": "Neuer Patient"
}
}
22 changes: 22 additions & 0 deletions src/locales/en/translation.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"actions": {
"edit": "Edit",
"save": "Save",
"cancel": "Cancel",
"new": "New",
"list": "List"
},
"dashboard": {
"label": "Dashboard"
},
"patient": {
"firstName": "First Name",
"lastName": "Last Name"
},
"patients": {
"label": "Patients",
"viewPatients": "View Patients",
"viewPatient": "View Patient",
"newPatient": "New Patient"
}
}
Loading

0 comments on commit dba5165

Please sign in to comment.