Files
mcde/lib/McdeSys/text.c
T
lotherk e6202a8019 McdeSys: the tool errors come from a catalog, German measured (t0282)
common.c's tool runner built its sentences as format strings, so every
dialog that shows mcde_sys_error() was English.  They are set 1 of
lib/McdeSys/mcdesys.msg now (9 messages: not there, cannot start, failed
with status, no pipe, no answer within N seconds, out of memory, the program
is not installed, the connector ended without an answer, cancelled), read by
lib/McdeSys/text.c (mcde_sys_msg, plain catopen/catgets; NLSPATH is set the
way DtSvc does when the session has none, from -DMCDE_DT_TOP=$(prefix)).
The German copy is programs/localized/de_DE.UTF-8/msg/mcdesys.msg, built by
msg.C.am into lib/nls/msg and listed in the PLIST (C plain, ${PLIST.nls} for
German).  A library does not call setlocale; the program does.

mcdesoundd gets no catalog: its only text is the log of a background daemon,
and the system layer stays English (AGENTS.md, language point 6).

Measured: a small program (setlocale + mcde_sys_run) prints
"/nonexistent/tool is not there." and "/bin/false did not succeed
(status 1)." with LANG=C, and "/nonexistent/tool ist nicht vorhanden." /
"/bin/false war nicht erfolgreich (Status 1)." with LANG=de_DE.UTF-8
(localedef/LOCPATH).  make mcde-linux MCDE_DIRS="install lib/McdeSys" and
"install programs/localized/C/msg" exit=0; MCDE_DIRS=plist: "3487 installed
names under dt/, 8682 in the PLISTs", ok.
2026-11-16 10:38:43 +00:00

42 lines
1.1 KiB
C

/*
* text.c -- McdeSys: the sentences of its errors, from a catalog
*
* License: CNCL 1.0 (Could Not Care Less), see LICENSE at the top of the tree.
*
* A sentence the user reads belongs in a catalog (ext/src/mcde/AGENTS.md,
* language): common.c's tool errors are set 1 of mcdesys.cat
* (lib/McdeSys/mcdesys.msg, the locale's copy in
* programs/localized/<locale>/msg). The catalog sits where the other CDE
* catalogs are, <prefix>/lib/nls/msg/<locale>/; when the session has no
* NLSPATH (a program started outside dtsession), this sets it the way CDE's
* DtSvc does.
*/
#define _POSIX_C_SOURCE 200809L
#include <locale.h>
#include <nl_types.h>
#include <stdlib.h>
#include <string.h>
#include <Mcde/McdeSys.h>
#include "private.h"
static nl_catd cat = (nl_catd) -1;
const char *
mcde_sys_msg(int n, const char *text)
{
if (cat == (nl_catd) -1) {
if (getenv("NLSPATH") == NULL)
(void) setenv("NLSPATH", MCDE_DT_TOP
"/lib/nls/msg/%L/%N.cat:" MCDE_DT_TOP
"/lib/nls/msg/C/%N.cat", 0);
cat = catopen("mcdesys", NL_CAT_LOCALE);
}
if (cat == (nl_catd) -1)
return text;
return catgets(cat, 1, n, text);
}