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

Commit

Permalink
Merge pull request #1892 from HospitalRun/add-translation-resources
Browse files Browse the repository at this point in the history
feat(i18n): Add translation resources
  • Loading branch information
fox1t authored Mar 10, 2020
2 parents eeb90d5 + 697552d commit d8494d7
Show file tree
Hide file tree
Showing 61 changed files with 625 additions and 176 deletions.
2 changes: 1 addition & 1 deletion src/__tests__/HospitalRun.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ describe('HospitalRun', () => {
expect(store.getActions()).toContainEqual(
addBreadcrumbs([
{ i18nKey: 'scheduling.appointments.label', location: '/appointments' },
{ i18nKey: 'scheduling.appointments.newAppointment', location: '/appointments/new' },
{ i18nKey: 'scheduling.appointments.new', location: '/appointments/new' },
{ i18nKey: 'dashboard.label', location: '/' },
]),
)
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/components/Navbar.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ describe('Navbar', () => {
'scheduling.appointments.label',
)
expect(scheduleLinkList.first().props().children[1].props.children).toEqual(
'scheduling.appointments.newAppointment',
'scheduling.appointments.new',
)
})

Expand Down
4 changes: 1 addition & 3 deletions src/__tests__/scheduling/appointments/Appointments.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,7 @@ describe('Appointments', () => {
})

const actualButtons: React.ReactNode[] = setButtonToolBarSpy.mock.calls[0][0]
expect((actualButtons[0] as any).props.children).toEqual(
'scheduling.appointments.newAppointment',
)
expect((actualButtons[0] as any).props.children).toEqual('scheduling.appointments.new')
})

it('should render a calendar with the proper events', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe('New Appointment', () => {
await setup()
})

expect(titleUtil.default).toHaveBeenCalledWith('scheduling.appointments.newAppointment')
expect(titleUtil.default).toHaveBeenCalledWith('scheduling.appointments.new')
})
})

Expand Down
2 changes: 1 addition & 1 deletion src/components/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const Navbar = () => {
},
{
type: 'link',
label: t('scheduling.appointments.newAppointment'),
label: t('scheduling.appointments.new'),
onClick: () => {
history.push('/appointments/new')
},
Expand Down
30 changes: 0 additions & 30 deletions src/i18n.js

This file was deleted.

64 changes: 64 additions & 0 deletions src/i18n.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import i18n from 'i18next'
import LanguageDetector from 'i18next-browser-languagedetector'
import { initReactI18next } from 'react-i18next'

import translationAR from './locales/ar/translations'
import translationDE from './locales/de/translations'
import translationEnUs from './locales/enUs/translations'
import translationES from './locales/es/translations'
import translationIN from './locales/in/translations'
import translationJA from './locales/ja/translations'
import translationPtBR from './locales/ptBr/translations'
import translationRU from './locales/ru/translations'
import translationZR from './locales/zr/translations'

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

i18n
// load translation using xhr -> see /public/locales
// learn more: https://github.com/i18next/i18next-xhr-backend
// detect user language
// learn more: https://github.com/i18next/i18next-browser-languageDetector
.use(LanguageDetector)
// pass the i18n instance to react-i18next.
.use(initReactI18next)
// init i18next
// for all options read: https://www.i18next.com/overview/configuration-options
.init({
fallbackLng: 'en',
debug: true,
resources,
interpolation: {
escapeValue: false, // not needed for react as it escapes by default
},
})

export default i18n
9 changes: 9 additions & 0 deletions src/locales/ar/translations/actions/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export default {
actions: {
edit: 'تصحيح',
save: 'حفظ',
cancel: 'إلغاء',
new: 'الجديد',
list: 'قائمة',
},
}
5 changes: 5 additions & 0 deletions src/locales/ar/translations/dashboard/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default {
dashboard: {
label: 'لوحة القيادة',
},
}
11 changes: 11 additions & 0 deletions src/locales/ar/translations/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import actions from './actions'
import dashboard from './dashboard'
import patient from './patient'
import patients from './patients'

export default {
...actions,
...dashboard,
...patient,
...patients,
}
6 changes: 6 additions & 0 deletions src/locales/ar/translations/patient/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
patient: {
firstName: 'الاسم الاول',
lastName: 'الكنية',
},
}
8 changes: 8 additions & 0 deletions src/locales/ar/translations/patients/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default {
patients: {
label: 'المرضى',
viewPatients: 'عرض المرضى',
viewPatient: 'عرض المريض',
newPatient: 'مريض جديد',
},
}
9 changes: 9 additions & 0 deletions src/locales/de/translations/actions/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export default {
actions: {
edit: 'Bearbeiten',
save: 'speichern',
cancel: 'Stornieren',
new: 'Neu',
list: 'Liste',
},
}
5 changes: 5 additions & 0 deletions src/locales/de/translations/dashboard/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default {
dashboard: {
label: 'Instrumententafel',
},
}
11 changes: 11 additions & 0 deletions src/locales/de/translations/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import actions from './actions'
import dashboard from './dashboard'
import patient from './patient'
import patients from './patients'

export default {
...actions,
...dashboard,
...patient,
...patients,
}
6 changes: 6 additions & 0 deletions src/locales/de/translations/patient/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
patient: {
firstName: 'Vorname',
lastName: 'Nachname',
},
}
8 changes: 8 additions & 0 deletions src/locales/de/translations/patients/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default {
patients: {
label: 'Patienten',
viewPatients: 'Patienten anzeigen',
viewPatient: 'Patient anzeigen',
newPatient: 'Neuer Patient',
},
}
136 changes: 0 additions & 136 deletions src/locales/en-US/translation.json

This file was deleted.

10 changes: 10 additions & 0 deletions src/locales/enUs/translations/actions/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export default {
actions: {
edit: 'Edit',
save: 'Save',
cancel: 'Cancel',
new: 'New',
list: 'List',
search: 'Search',
},
}
5 changes: 5 additions & 0 deletions src/locales/enUs/translations/dashboard/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default {
dashboard: {
label: 'Dashboard',
},
}
Loading

1 comment on commit d8494d7

@vercel
Copy link

@vercel vercel bot commented on d8494d7 Mar 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please # to comment.