From fd9adf2534b99a1c25203fb2738e7035f783d8fb Mon Sep 17 00:00:00 2001 From: Chukwudumebi Onwuli <37223065+deeonwuli@users.noreply.github.com> Date: Mon, 1 Jul 2024 09:18:37 +0100 Subject: [PATCH] fix: set default app namespace (#14) --- i18n/es.po | 2 +- package.json | 2 +- src/types/i18n.d.ts | 1 + src/webapp/contexts/app-context.ts | 2 ++ 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/i18n/es.po b/i18n/es.po index c14c658..b8ba95e 100644 --- a/i18n/es.po +++ b/i18n/es.po @@ -9,7 +9,7 @@ msgstr "" "Plural-Forms: nplurals=2; plural=(n != 1)\n" msgid "Select Dashboard" -msgstr "" +msgstr "Seleccionar panel" msgid "Select Month" msgstr "" diff --git a/package.json b/package.json index 8c3d195..cfc375b 100644 --- a/package.json +++ b/package.json @@ -101,7 +101,7 @@ "eject": "react-scripts eject", "prettify": "prettier \"./**/*.{js,jsx,json,css,ts,tsx}\" --write", "extract-pot": "yarn d2-i18n-extract -p src/ -o i18n/", - "localize": "yarn update-po && d2-i18n-generate -n dhis2-skeleton-app -p ./i18n/ -o ./src/locales/", + "localize": "yarn update-po && d2-i18n-generate -n dashboard-reports -p ./i18n/ -o ./src/locales/", "update-po": "yarn extract-pot && find i18n/ -name '*.po' -exec msgmerge --backup=off -U {} i18n/en.pot \\;", "manifest": "d2-manifest package.json build/manifest.webapp", "cy:verify": "cypress verify", diff --git a/src/types/i18n.d.ts b/src/types/i18n.d.ts index 168a99a..636fc49 100644 --- a/src/types/i18n.d.ts +++ b/src/types/i18n.d.ts @@ -1,4 +1,5 @@ declare module "@dhis2/d2-i18n" { export function t(value: string, namespace?: object): string; export function changeLanguage(locale: string); + export function setDefaultNamespace(namespace: string); } diff --git a/src/webapp/contexts/app-context.ts b/src/webapp/contexts/app-context.ts index 29675a3..1a9b84a 100644 --- a/src/webapp/contexts/app-context.ts +++ b/src/webapp/contexts/app-context.ts @@ -3,6 +3,7 @@ import { CompositionRoot } from "../../CompositionRoot"; import { Settings } from "../../domain/entities/Settings"; import { User } from "../../domain/entities/User"; import { D2Api } from "../../types/d2-api"; +import i18n from "../../locales"; export interface AppContextState { api: D2Api; @@ -17,6 +18,7 @@ export const AppContext = React.createContext(null); export function useAppContext() { const context = useContext(AppContext); + i18n.setDefaultNamespace("dashboard-reports"); if (context) { return context; } else {