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

feat(i18n): add translation resources #1668

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
03729e5
feat(i18n): add translation resources
ocBruno Dec 11, 2019
b1e830c
refactor: improve-translation-resources-structure
ocBruno Dec 13, 2019
642d5fe
refactor: organize static translations into subfolders
ocBruno Jan 5, 2020
83923b2
refactor: rename translations folder
ocBruno Jan 5, 2020
761deda
feat(i18n): reorganize public translation resources
ocBruno Jan 7, 2020
98c25b9
fix(i18n): fix file type and import
ocBruno Jan 7, 2020
6e70533
updates components
matteovivona Jan 10, 2020
59680a0
fix(i18n): fix search button properties
ocBruno Jan 12, 2020
dba5165
fix(i18n): fix i18n translation keys and reorganize files
ocBruno Jan 12, 2020
b4135b8
refactor(i18n): reorganize and decouple translation resources
ocBruno Jan 31, 2020
cf305bc
fix(i18n): fix file type
ocBruno Jan 31, 2020
97e01d9
fix(conflict): merge master
ocBruno Jan 31, 2020
0726ac3
fix(i18n): merge changes from upstream
ocBruno Jan 31, 2020
d9b7722
feat(i18n): update and resolve testing and lint issues
ocBruno Jan 31, 2020
f60fcf4
Merge branch 'master' into add-translation-resources
Jan 31, 2020
c7fd937
fix(navbar): add missing i18n t function
ocBruno Jan 31, 2020
553deda
Merge branch 'add-translation-resources' of https://github.com/ocBrun…
ocBruno Jan 31, 2020
1006506
Merge branch 'master' into add-translation-resources
Feb 2, 2020
68bb92c
fix(i18n): update translation resources for enUs and ptBr
ocBruno Feb 2, 2020
0a23b8c
fix(test): update patient slice test to match resource update
ocBruno Feb 3, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/__tests__/scheduling/appointments-slice.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { AnyAction } from 'redux'
import Appointment from 'model/Appointment'
import { createMemoryHistory } from 'history'
import AppointmentRepository from 'clients/db/AppointmentsRepository'
import { mocked } from 'ts-jest/utils'
import appointments, {
createAppointmentStart,
createAppointment,
} from '../../scheduling/appointments/appointments-slice'
import { mocked } from 'ts-jest/utils'

describe('appointments slice', () => {
describe('appointments reducer', () => {
Expand Down
26 changes: 10 additions & 16 deletions src/components/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,27 @@ const Navbar = () => {
history.push('/')
},
}}
bg="dark"
variant="dark"
search={{
onClickButton: () => {
// no oop
},
onChangeInput: () => {
// no oop
},
placeholderText: t('actions.search'),
buttonText: t('actions.search'),
placeholderText: t('actions.search'),
onClickButton: () => undefined,
onChangeInput: () => undefined,
}}
navLinks={[
{
label: t('patients.label'),
onClick: () => {
// no oop
},
label: t('patients.label', 'patients'),
onClick: () => undefined,
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 All @@ -48,9 +44,7 @@ const Navbar = () => {
},
{
label: t('scheduling.label'),
onClick: () => {
// no oop
},
onClick: () => undefined,
children: [
{
label: t('scheduling.appointments.label'),
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',
},
}
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',
},
}
17 changes: 17 additions & 0 deletions src/locales/enUs/translations/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import actions from './actions'
import dashboard from './dashboard'
import patient from './patient'
import patients from './patients'
import scheduling from './scheduling'
import states from './states'
import sex from './sex'

export default {
...actions,
...dashboard,
...patient,
...patients,
...scheduling,
...states,
...sex,
}
43 changes: 43 additions & 0 deletions src/locales/enUs/translations/patient/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
export default {
patient: {
firstName: 'First Name',
lastName: 'Last Name',
suffix: "Suffix",
prefix: "Prefix",
givenName: "Given Name",
familyName: "Family Name",
dateOfBirth: "Date of Birth",
approximateDateOfBirth: "Approximate Date of Birth",
age: "Age",
approximateAge: "Approximate Age",
placeOfBirth: "Place of Birth",
sex: "Sex",
phoneNumber: "Phone Number",
email: "Email",
address: "Address",
occupation: "Occupation",
type: "Patient Type",
preferredLanguage: "Preferred Language",
basicInformation: "Basic Information",
generalInformation: "General Information",
contactInformation: "Contact Information",
unknownDateOfBirth: "Unknown",
relatedPerson: "Related Person",
relatedPersons: {
error: {
relatedPersonRequired: "Related Person is required.",
relationshipTypeRequired: "Relationship Type is required."
},
label: "Related Persons",
new: "New Related Person",
relationshipType: "Relationship Type"
},
types: {
charity: "Charity",
private: "Private"
},
errors: {
patientGivenNameRequired: "Patient Given Name is required."
}
},
}
9 changes: 9 additions & 0 deletions src/locales/enUs/translations/patients/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export default {
patients: {
label: 'Patients',
viewPatients: 'View Patients',
viewPatient: 'View Patient',
newPatient: 'New Patient',
successfullyCreated: "Successfully created patient"
},
}
29 changes: 29 additions & 0 deletions src/locales/enUs/translations/scheduling/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
export default {
scheduling: {
label: "Scheduling",
appointments: {
label: "Appointments",
new: "New Appointment"
},
appointment: {
startDate: "Start Date",
endDate: "End Date",
location: "Location",
type: "Type",
types: {
checkup: "Checkup",
emergency: "Emergency",
followUp: "Follow Up",
routine: "Routine",
walkUp: "Walk Up"
},
errors: {
patientRequired: "Patient is required.",
errorCreatingAppointment: "Error Creating Appointment!",
startDateMustBeBeforeEndDate: "Start Time must be before End Time."
},
reason: "Reason",
patient: "Patient"
}
},
}
8 changes: 8 additions & 0 deletions src/locales/enUs/translations/sex/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default {
sex: {
male: "Male",
female: "Female",
other: "Other",
unknown: "Unknown"
},
}
6 changes: 6 additions & 0 deletions src/locales/enUs/translations/states/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
states: {
success: "Success!",
error: "Error!"
},
}
9 changes: 9 additions & 0 deletions src/locales/es/translations/actions/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export default {
actions: {
edit: 'Editar',
save: 'Guardar',
cancel: 'Cancelar',
new: 'Nuevo',
list: 'Lista',
},
}
5 changes: 5 additions & 0 deletions src/locales/es/translations/dashboard/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default {
dashboard: {
label: 'Panel',
},
}
Loading