From 6a620b125abab429ea69d44a4f7304d949896a7d Mon Sep 17 00:00:00 2001 From: lotherk Date: Mon, 16 Nov 2026 10:18:17 +0000 Subject: [PATCH] MCDE dtphoto: a message catalog, German measured (t0282) dtphoto's own sentences and titles come from programs/dtphoto/dtphoto.msg (set 1, 5 messages: the toolbox window title "Tools", the status line "Scratch: 1.2M/50M", the "Doc: %dK/%dK" format, the open and the save error), the German copy in programs/localized/de_DE.UTF-8/msg/dtphoto.msg, built by msg.C.am and listed in the PLIST (C plain, ${PLIST.nls} for German). Like dtlaunch it calls catopen/catgets itself and setlocale in main before its first message. The menus stay as they are: dtphoto.menu follows docs/reference/photoshop-ui.csv -- the programme's look -- and the command lookup matches those English labels, so they are not a catalog. Measured on Xvfb (1280x800, fresh HOME, ttsession + dtwm), de_DE.UTF-8 via localedef/LOCPATH: the toolbox is titled "Werkzeuge", the status line reads "Dok: 225K/1125K" and "Arbeitsspeicher: 1.2M/50M" (/tmp/opencode/dtp-de.png); LANG=C: "Tools", "Doc: 225K/1125K", "Scratch: 1.2M/50M" (/tmp/opencode/dtp-c.png). make mcde-linux MCDE_DIRS="install programs/dtphoto" and "install programs/localized/C/msg" exit=0; MCDE_DIRS=plist: "3485 installed names under dt/, 8678 in the PLISTs", ok. --- AGENTS.md | 5 ++- pkgsrc/PLIST | 2 ++ programs/dtphoto/dtphoto.c | 36 ++++++++++++++++--- programs/dtphoto/dtphoto.msg | 9 +++++ .../localized/de_DE.UTF-8/msg/dtphoto.msg | 9 +++++ programs/localized/templates/msg.C.am | 6 +++- 6 files changed, 60 insertions(+), 7 deletions(-) create mode 100644 programs/dtphoto/dtphoto.msg create mode 100644 programs/localized/de_DE.UTF-8/msg/dtphoto.msg diff --git a/AGENTS.md b/AGENTS.md index 4cf7cff4..8874fe81 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -52,7 +52,10 @@ narratives and test notes, is `docs/reference/mcde-agents-history-2026-11-13.txt messages: the window title and the "no menu" label) does the same and calls `setlocale` in main before its first message; the menu labels themselves come from the person's chestrc, which is their file, not a - catalog. A new catalog must be added to + catalog. dtphoto (`dtphoto.msg`, 5 messages: the toolbox title, the two + status lines and the open/save errors) keeps its menus as the reference's + (`dtphoto.menu`, docs/reference/photoshop-ui.csv) -- they are the look of + the program, not its sentences. A new catalog must be added to `programs/localized/templates/msg.C.am` for C and to the PLIST (C plain, a locale with `${PLIST.nls}`). diff --git a/pkgsrc/PLIST b/pkgsrc/PLIST index 6e9eb934..6a0c092c 100644 --- a/pkgsrc/PLIST +++ b/pkgsrc/PLIST @@ -2783,6 +2783,7 @@ dt/lib/nls/msg/C/dtmailopts.cat dt/lib/nls/msg/C/dtpad.cat dt/lib/nls/msg/C/dtpdm.cat dt/lib/nls/msg/C/dtpdmd.cat +dt/lib/nls/msg/C/dtphoto.cat dt/lib/nls/msg/C/dtprintinfo.cat dt/lib/nls/msg/C/dtscreen.cat dt/lib/nls/msg/C/dtsearch.cat @@ -7517,6 +7518,7 @@ ${PLIST.nls}dt/lib/nls/msg/de_DE.UTF-8/dtmailopts.cat ${PLIST.nls}dt/lib/nls/msg/de_DE.UTF-8/dtpad.cat ${PLIST.nls}dt/lib/nls/msg/de_DE.UTF-8/dtpdm.cat ${PLIST.nls}dt/lib/nls/msg/de_DE.UTF-8/dtpdmd.cat +${PLIST.nls}dt/lib/nls/msg/de_DE.UTF-8/dtphoto.cat ${PLIST.nls}dt/lib/nls/msg/de_DE.UTF-8/dtprintinfo.cat ${PLIST.nls}dt/lib/nls/msg/de_DE.UTF-8/dtscreen.cat ${PLIST.nls}dt/lib/nls/msg/de_DE.UTF-8/dtsearch.cat diff --git a/programs/dtphoto/dtphoto.c b/programs/dtphoto/dtphoto.c index 088a1608..d9809dad 100644 --- a/programs/dtphoto/dtphoto.c +++ b/programs/dtphoto/dtphoto.c @@ -17,6 +17,8 @@ #include #include +#include +#include #include #include @@ -386,6 +388,27 @@ MakeAccel(const char *key, char *out, size_t size) static void MenuCallback(Widget w, XtPointer data, XtPointer call); +/* dtphoto's message catalog (programs/dtphoto/dtphoto.msg, the locale's + * copy in programs/localized//msg, under lib/nls/msg). The menus + * stay as the reference's (dtphoto.menu, docs/reference/photoshop-ui.csv): + * they are the look of the program, not its sentences. */ +static nl_catd cat = (nl_catd) -1; + +static const char * +Tr(int n, const char *text) +{ + if (cat == (nl_catd) -1) { + if (getenv("NLSPATH") == NULL) + (void) setenv("NLSPATH", CDE_INSTALLATION_TOP + "/lib/nls/msg/%L/%N.cat:" CDE_INSTALLATION_TOP + "/lib/nls/msg/C/%N.cat", 0); + cat = catopen("dtphoto", NL_CAT_LOCALE); + } + if (cat == (nl_catd) -1) + return text; + return catgets(cat, 1, n, text); +} + static Widget BuildMenu(Widget parent, Menu *m) { @@ -454,7 +477,8 @@ UpdateStatus(void) snprintf(buf, sizeof buf, "%d%%", zoom); XtVaSetValues(statusZoom, XmNlabelString, XmStringCreateLocalized(buf), NULL); - snprintf(buf, sizeof buf, "Doc: %dK/%dK", docW * docH * 3 / 1024, + snprintf(buf, sizeof buf, Tr(3, "Doc: %dK/%dK"), + docW * docH * 3 / 1024, docW * docH * 3 / 1024 + 900); XtVaSetValues(statusDoc, XmNlabelString, XmStringCreateLocalized(buf), NULL); @@ -976,8 +1000,8 @@ FileOk(Widget w, XtPointer data, XtPointer call) XtVaSetValues(d, XmNmessageString, XmStringCreateLocalized(save ? - "The picture could not be saved." : - "The picture could not be opened."), NULL); + Tr(5, "The picture could not be saved.") : + Tr(4, "The picture could not be opened.")), NULL); XtUnmanageChild(XmMessageBoxGetChild(d, XmDIALOG_CANCEL_BUTTON)); XtManageChild(d); @@ -1094,6 +1118,8 @@ MenuCallback(Widget w, XtPointer data, XtPointer call) int main(int argc, char **argv) { + /* before the first Tr(): the catalog is opened for the locale */ + (void) setlocale(LC_ALL, ""); XtAppContext app; Widget mainw, menubar, form; char path[512]; @@ -1162,13 +1188,13 @@ main(int argc, char **argv) XmATTACH_FORM, XmNalignment, XmALIGNMENT_END, XmNrecomputeSize, False, XmNwidth, 220, NULL); XtVaSetValues(statusScratch, XmNlabelString, - XmStringCreateLocalized("Scratch: 1.2M/50M"), NULL); + XmStringCreateLocalized(Tr(2, "Scratch: 1.2M/50M")), NULL); XtVaSetValues(top, XmNtitle, "dtphoto", NULL); XtRealizeWidget(top); toolShell = XtVaAppCreateShell("tools", "Dtphoto", - topLevelShellWidgetClass, dpy, XmNtitle, "Tools", + topLevelShellWidgetClass, dpy, XmNtitle, Tr(1, "Tools"), XmNallowShellResize, True, XmNx, 8, XmNy, 64, NULL); BuildToolbox(toolShell, dpy); XtRealizeWidget(toolShell); diff --git a/programs/dtphoto/dtphoto.msg b/programs/dtphoto/dtphoto.msg new file mode 100644 index 00000000..63e8a458 --- /dev/null +++ b/programs/dtphoto/dtphoto.msg @@ -0,0 +1,9 @@ +$ MCDE dtphoto message catalog (set 1) -- English is the source; a locale's copy lives in programs/localized//msg/dtphoto.msg. The menus stay as the reference's (dtphoto.menu). +$ +$set 1 + +1 Tools +2 Scratch: 1.2M/50M +3 Doc: %dK/%dK +4 The picture could not be opened. +5 The picture could not be saved. diff --git a/programs/localized/de_DE.UTF-8/msg/dtphoto.msg b/programs/localized/de_DE.UTF-8/msg/dtphoto.msg new file mode 100644 index 00000000..4e6342b0 --- /dev/null +++ b/programs/localized/de_DE.UTF-8/msg/dtphoto.msg @@ -0,0 +1,9 @@ +$ MCDE dtphoto message catalog, German. +$ +$set 1 + +1 Werkzeuge +2 Arbeitsspeicher: 1.2M/50M +3 Dok: %dK/%dK +4 Das Bild konnte nicht geƶffnet werden. +5 Das Bild konnte nicht gespeichert werden. diff --git a/programs/localized/templates/msg.C.am b/programs/localized/templates/msg.C.am index 88cca7e2..db6ffe10 100644 --- a/programs/localized/templates/msg.C.am +++ b/programs/localized/templates/msg.C.am @@ -5,7 +5,7 @@ BUILT_SOURCES = Xm.cat Mrm.cat Uil.cat DtHelp.cat DtMail.cat \ DtPrint.cat DtWidget.cat MotifApp.cat SUNW_TOOLTALK.cat dt.cat \ dtact.cat dtbuilder.cat dtcalc.cat dtcm.cat dtcodegen.cat \ - dtbar.cat dtconfig.cat dttoolbox.cat dtlaunch.cat dtsystemsettings.cat dtcopy.cat dtcreate.cat dtfile.cat dthello.cat \ + dtbar.cat dtconfig.cat dtphoto.cat dttoolbox.cat dtlaunch.cat dtsystemsettings.cat dtcopy.cat dtcreate.cat dtfile.cat dthello.cat \ dthelpgen.cat dthelpprint.cat dticon.cat dtimsstart.cat \ dtlogin.cat dtlp.cat dtmailopts.cat dtpad.cat \ dtpdm.cat dtpdmd.cat dtprintinfo.cat dtscreen.cat dtsearch.cat \ @@ -125,6 +125,10 @@ dttoolbox.cat: $(TOP)/dttoolbox/dttoolbox.msg $(RM) $@ LANG=C $(GENCAT) $@ $^ || $(RM) $@ +dtphoto.cat: $(TOP)/dtphoto/dtphoto.msg + $(RM) $@ + LANG=C $(GENCAT) $@ $^ || $(RM) $@ + dtfile.cat: $(TOP)/dtfile/dtfile.msg $(RM) $@ LANG=C $(GENCAT) $@ $^ || $(RM) $@