Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use default app namespace #55

Merged
merged 1 commit into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ msgid "- All -"
msgstr ""

msgid "Loading..."
msgstr ""
msgstr "Cargando..."

msgid "Organisation unit"
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,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 d2-reports -p ./i18n/ -o ./src/locales/",
"localize": "yarn update-po && d2-i18n-generate -n d2-autogen-forms -p ./i18n/ -o ./src/locales/",
"update-po": "yarn extract-pot && for pofile in i18n/*.po; do msgmerge --backup=off -U $pofile i18n/en.pot; done",
"manifest": "d2-manifest package.json build/manifest.webapp",
"configurator-manifest": "d2-manifest package.json manifest.webapp --manifest.version=$npm_package_appVersions_configurator --manifest.name='Autogenerated Forms Configurator' --manifest.description='Autogenerated Forms Configurator'",
Expand Down
1 change: 1 addition & 0 deletions src/types/i18n.d.ts
Original file line number Diff line number Diff line change
@@ -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);
}
2 changes: 2 additions & 0 deletions src/webapp/contexts/app-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { useContext } from "react";
import { CompositionRoot } from "../../compositionRoot";
import { Config } from "../../domain/common/entities/Config";
import { D2Api } from "../../types/d2-api";
import i18n from "../../locales";

export interface AppContextState {
api: D2Api;
Expand All @@ -13,6 +14,7 @@ export const AppContext = React.createContext<AppContextState | null>(null);

export function useAppContext() {
const context = useContext(AppContext);
i18n.setDefaultNamespace("d2-autogen-forms");
if (context) {
return context;
} else {
Expand Down
Loading