LC_MESSAGES
Determine the locale that should be used to affect the format
and contents of diagnostic messages written to standard error.
But it doesn't work for man(1). After little investigation I've learned that man(1) uses catgets(3) to get an error string. The catalog descriptor for catgets(3) is received from catopen(3) which (in case $LC_MESSAGES=C) carefully tries to open /usr/share/locale/C and some other dirs with C locale and finally fallbacks to /usr/share/locale/ru. If man(1) obtains an empty string from catgets(3) it looks for it in builtin table which is what I need.
As for now I can't say which part of this complicated situation is buggy, so I've inserted a hack into man(1) to get an error string right from builtin table if the locale is C or POSIX.
Here is my patch.
diff -rNu a/man-1.6f/src/gripes.c b/man-1.6f/src/gripes.c
--- a/man-1.6f/src/gripes.c 2006-11-21 22:53:44.000000000 +0300
+++ b/man-1.6f/src/gripes.c 2009-08-11 10:36:08.000000000 +0400
@@ -99,15 +99,22 @@
static char *
getmsg (int n) {
char *s = "";
-
- catinit ();
- if (catfd != (nl_catd) -1) {
- s = catgets(catfd, 1, n, "");
- if (*s && is_suspect(s))
- s = "";
- }
- if (*s == 0 && 0 < n && n <= MAXMSG)
- s = msg[n];
+ char *lm;
+
+ lm = getenv("LC_MESSAGES");
+ if (lm && (!strcmp(lm, "C") || !strcmp(lm, "POSIX"))) {
+ if (0 < n && n <= MAXMSG)
+ s = msg[n];
+ } else {
+ catinit ();
+ if (catfd != (nl_catd) -1) {
+ s = catgets(catfd, 1, n, "");
+ if (*s && is_suspect(s))
+ s = "";
+ }
+ if (*s == 0 && 0 < n && n <= MAXMSG)
+ s = msg[n];
+ }
if (*s == 0) {
fprintf(stderr,
"man: internal error - cannot find message %d\n", n);