Skip to content

Commit

Permalink
(feat) Add translations for the Home breadcrumb link and left nav link (
Browse files Browse the repository at this point in the history
  • Loading branch information
vasharma05 authored Oct 6, 2023
1 parent f4f8801 commit 008ebaa
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 32 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,6 @@ dist
!.yarn/releases
!.yarn/sdks
!.yarn/versions

# i18next parser creating moduleName folder when parsing index.ts
moduleName
2 changes: 1 addition & 1 deletion packages/esm-home-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"lint": "cross-env TIMING=1 eslint src --ext ts,tsx --fix --max-warnings=0 --color",
"typescript": "tsc",
"verify": "turbo lint typescript test --color",
"extract-translations": "i18next 'src/**/*.{component.tsx,tsx}' --config ../../tools/i18next-parser.config.js",
"extract-translations": "i18next 'src/**/*.{component.tsx,tsx}' 'src/index.ts' --config ../../tools/i18next-parser.config.js",
"test": "cross-env TZ=UTC jest --config jest.config.js --verbose false --passWithNoTests",
"coverage": "yarn test --coverage"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import React, { useMemo } from 'react';
import { BrowserRouter, useLocation } from 'react-router-dom';
import { ConfigurableLink } from '@openmrs/esm-framework';
import { useTranslation } from 'react-i18next';

export interface DashboardLinkConfig {
name: string;
title: string;
}

const DashboardLink = ({ dashboardLinkConfig }: { dashboardLinkConfig: DashboardLinkConfig }) => {
const { t } = useTranslation();
const { name } = dashboardLinkConfig;
const location = useLocation();
const spaBasePath = `${window.spaBase}/home`;
Expand All @@ -23,7 +25,8 @@ const DashboardLink = ({ dashboardLinkConfig }: { dashboardLinkConfig: Dashboard
to={spaBasePath}
className={`cds--side-nav__link ${navLink === 'home' && 'active-left-nav-link'}`}
>
{name}
{/* t('Home', 'Home') */}
{t(name)}
</ConfigurableLink>
);
};
Expand Down
5 changes: 3 additions & 2 deletions packages/esm-home-app/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { registerBreadcrumbs, defineConfigSchema, getAsyncLifecycle, getSyncLifecycle } from '@openmrs/esm-framework';
import { createDashboardLink } from './createDashboardLink';
import { createDashboardLink } from './createDashboardLink.component';
import { dashboardMeta } from './dashboard.meta';
import { esmHomeSchema } from './openmrs-esm-home-schema';

Expand All @@ -26,11 +26,12 @@ export const homeWidgetDashboard = getAsyncLifecycle(

export function startupApp() {
defineConfigSchema(moduleName, esmHomeSchema);
// t('Home', 'Home');

registerBreadcrumbs([
{
path: `${window.spaBase}/${pageName}`,
title: 'Home',
title: () => Promise.resolve(window.i18next.t('Home', { defaultValue: 'Home', ns: moduleName })),
},
]);
}
3 changes: 3 additions & 0 deletions packages/esm-home-app/translations/am.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"Home": "Home"
}
8 changes: 1 addition & 7 deletions packages/esm-home-app/translations/en.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
{
"activeVisits": "Active Visits",
"appointmentScheduling": "Appointment Scheduling",
"captureVitals": "Capture Vitals",
"configureMetadata": "Configure Metadata",
"dataManagement": "Data Management",
"reports": "Reports",
"systemAdministration": "System Administration"
"Home": "Home"
}
8 changes: 1 addition & 7 deletions packages/esm-home-app/translations/es.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
{
"activeVisits": "Visitas Activas",
"appointmentScheduling": "Programación de Citas",
"captureVitals": "Captura de Signos Vitales",
"configureMetadata": "Configuración de Metadatos",
"dataManagement": "Gestión de Datos",
"reports": "Informes",
"systemAdministration": "Administración del Sistema"
"Home": "Home"
}
8 changes: 1 addition & 7 deletions packages/esm-home-app/translations/fr.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
{
"activeVisits": "Visites actives",
"appointmentScheduling": "Planification de rendez-vous",
"captureVitals": "Entrer les signes vitaux",
"configureMetadata": "Configurer les métadonnées",
"dataManagement": "Gestion de données",
"reports": "Rapports",
"systemAdministration": "Administration du système"
"Home": "Home"
}
8 changes: 1 addition & 7 deletions packages/esm-home-app/translations/he.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
{
"activeVisits": "ביקורים פעילים",
"appointmentScheduling": "תזמון תורים",
"captureVitals": "לכידת נתוני חיים",
"configureMetadata": "הגדרת מטה-נתונים",
"dataManagement": "ניהול נתונים",
"reports": "דוחות",
"systemAdministration": "ניהול מערכת"
"Home": "Home"
}
3 changes: 3 additions & 0 deletions packages/esm-home-app/translations/km.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"Home": "ផ្ទះ"
}

0 comments on commit 008ebaa

Please sign in to comment.