Dear Karl, dear all!

Short description: makeinfo: locale settings should not influence output
files

Long description:
        see http://bugs.debian.org/113988

You already mention in the TODO file that it would be good to use the
document language instead of LANG for translating some messages (liek
Next, Previous etc).

On Die, 07 Mär 2006, Sven Joachim wrote:
> ,----
> | * Makeinfo:
> |   - [...]
> |   - Use @documentlanguage instead of LANG for many translations.
> `----
> 
> If this could be implemented (and authors use @documentlanguage), it
> would solve the problem.

I took a look at the code and I couldn't implement THIS one, but what I
did is the following:

- Add a cmd line option --document-language=STR where STR should be
  a string which can be used for LC_ALL=str
- define a function getdocumenttext which is aliased to __ which does
  the following: save the current locale, set the current locale to
  the value as set with the above option (or C if not set at all),
  translates the message, resets the LC_ALL to the saved value
- changed all occurrences (I found) of _("Next") etc to __("Next").

I tested the attached patch against texinfo/makeinfo 4.8 and it worked,
so my locale settings are not taken into account when translating the
messages.

What is missing: Merge @documentlanguage with the above variable (I
called it interface_langauge). This is not completely trivial as the
documentlanguage is a 2 letter code, while the LANG/LC_ALL setting
usually is something like de_AT etc. Furthermore I don't know WHEN the
@docuemntlanguage is set, but it might be enough to change it in the
respective callback function cm_documentlanguage, but how to expand the
2 letter code to a full setting?


Karl: Please comment on this, what do you think, could we include
something like this?

Sven, Julian: What this solve the problems you have?
  (and btw, it took me without C knowledge to hack this in 1h, so if
  this would be so important (as mentioned in the last emails) than
  one might have managed to fix this in the last 5 years since the
  bug is open).

Best wishes

Norbert

-------------------------------------------------------------------------------
Dr. Norbert Preining <preining AT logic DOT at>             Università di Siena
gpg DSA: 0x09C5B094      fp: 14DF 2E6C 0307 BE6D AD76  A9C0 D2BF 4AA3 09C5 B094
-------------------------------------------------------------------------------
PLYMOUTH (vb.)
To relate an amusing story to someone without remembering that it was
they who told it to you in the first place.
                        --- Douglas Adams, The Meaning of Liff
diff -urN trunk/makeinfo/html.c foo/makeinfo/html.c
--- trunk/makeinfo/html.c       2006-02-16 13:03:48.000000000 +0100
+++ foo/makeinfo/html.c 2006-03-07 11:08:46.000000000 +0100
@@ -204,7 +204,7 @@
   /* The <title> should not have markup, so use text_expansion.  */
   if (!html_title)
     html_title = escape_string (title ?
-        text_expansion (title) : (char *) _("Untitled"));
+        text_expansion (title) : (char *) __("Untitled"));
 
   /* Make sure this is the very first string of the output document.  */
   output_paragraph_offset = 0;
diff -urN trunk/makeinfo/lang.c foo/makeinfo/lang.c
--- trunk/makeinfo/lang.c       2006-02-16 13:03:48.000000000 +0100
+++ foo/makeinfo/lang.c 2006-03-07 11:47:04.000000000 +0100
@@ -33,6 +33,9 @@
 /* Current language code; default is English.  */
 language_code_type language_code = en;
 
+/* interface_language. */
+char interface_language[21] = "C";
+
 /* By default, unsupported encoding is an empty string.  */
 char *unknown_encoding = NULL;
 
diff -urN trunk/makeinfo/lang.h foo/makeinfo/lang.h
--- trunk/makeinfo/lang.h       2006-02-16 13:03:48.000000000 +0100
+++ foo/makeinfo/lang.h 2006-03-07 11:44:40.000000000 +0100
@@ -145,4 +145,6 @@
 
 extern char *current_document_encoding (void);
 
+extern char interface_language[21];
+
 #endif /* not LANG_H */
diff -urN trunk/makeinfo/makeinfo.c foo/makeinfo/makeinfo.c
--- trunk/makeinfo/makeinfo.c   2006-02-16 13:03:48.000000000 +0100
+++ foo/makeinfo/makeinfo.c     2006-03-07 11:48:37.000000000 +0100
@@ -350,6 +350,8 @@
     printf (_("\
 General options:\n\
       --error-limit=NUM       quit after NUM errors (default %d).\n\
+      --document-language=STR locale to be used in translating certain\n\
+                              keywords in the output file (default C).\n\
       --force                 preserve output even if errors.\n\
       --help                  display this help and exit.\n\
       --no-validate           suppress node cross-reference validation.\n\
@@ -478,6 +480,7 @@
   { "css-include", 1, 0, 'C' },
   { "docbook", 0, 0, 'd' },
   { "enable-encoding", 0, &enable_encoding, 1 },
+  { "document-language", 1, 0, 'l' },
   { "error-limit", 1, 0, 'e' },
   { "fill-column", 1, 0, 'f' },
   { "footnote-style", 1, 0, 's' },
@@ -685,6 +688,11 @@
           append_to_include_path (optarg);
           break;
 
+       case 'l':
+         /* save the language code */
+         strncpy(interface_language, optarg, 20);
+         break;
+
         case 'i':
           if (sscanf (optarg, "%d", &xml_indentation_increment) != 1)
             {
@@ -4155,3 +4163,14 @@
     }
   return 0;
 }
+
+char *getdocumenttext (const char *msgid)
+{
+  char *safedlocale;
+  char *s;
+  safedlocale = setlocale(LC_ALL,NULL);
+  setlocale(LC_ALL,interface_language);
+  s=gettext(msgid);
+  setlocale(LC_ALL,safedlocale);
+  return(s);
+}
diff -urN trunk/makeinfo/makeinfo.h foo/makeinfo/makeinfo.h
--- trunk/makeinfo/makeinfo.h   2006-02-16 13:03:48.000000000 +0100
+++ foo/makeinfo/makeinfo.h     2006-03-07 10:59:54.000000000 +0100
@@ -316,6 +316,10 @@
   struct generic_list *next;
 } GENERIC_LIST;
 
+/* gettext for file generation */
+extern char *getdocumenttext (const char *msgid);
+#define __(s) getdocumenttext(s)
+
 /* Reverse the order of a list.  */
 extern GENERIC_LIST * reverse_list (GENERIC_LIST *list);
 
diff -urN trunk/makeinfo/node.c foo/makeinfo/node.c
--- trunk/makeinfo/node.c       2006-02-16 13:03:48.000000000 +0100
+++ foo/makeinfo/node.c 2006-03-07 11:04:53.000000000 +0100
@@ -988,7 +988,7 @@
           if (next)
             {
               tem = expansion (next, 0);
-             add_word ((char *) _("Next:"));
+             add_word ((char *) __("Next:"));
               add_word ("&nbsp;");
               
              add_word ("<a rel=\"next\" accesskey=\"n\" href=\"");
@@ -1004,7 +1004,7 @@
           if (prev)
             {
               tem = expansion (prev, 0);
-             add_word ((char *) _("Previous:"));
+             add_word ((char *) __("Previous:"));
               add_word ("&nbsp;");
              add_word ("<a rel=\"previous\" accesskey=\"p\" href=\"");
              add_anchor_name (tem, 1);
@@ -1018,7 +1018,7 @@
           if (up)
             {
               tem = expansion (up, 0);
-             add_word ((char *) _("Up:"));
+             add_word ((char *) __("Up:"));
               add_word ("&nbsp;");
              add_word ("<a rel=\"up\" accesskey=\"u\" href=\"");
              add_anchor_name (tem, 1);
@@ -1360,9 +1360,9 @@
   switch (type)
     {
     case menu_reference:
-      return _("Menu");
+      return __("Menu");
     case followed_reference:
-      return _("Cross");
+      return __("Cross");
     default:
       return "Internal-bad-reference-type";
     }
@@ -1421,7 +1421,7 @@
       /* If this node has a Next, then make sure that the Next exists. */
       if (tags->next)
         {
-          validate (tags->next, tags->line_no, _("Next"));
+          validate (tags->next, tags->line_no, __("Next"));
 
           /* If the Next node exists, and there is no Up, then make sure
              that the Prev of the Next points back.  But do nothing if
@@ -1459,7 +1459,7 @@
          field at this stage. */
       if (!(tags->flags & TAG_FLAG_PREV_ERROR) && tags->prev)
         {
-          int valid_p = validate (tags->prev, tags->line_no, _("Prev"));
+          int valid_p = validate (tags->prev, tags->line_no, __("Prev"));
 
           if (!valid_p)
             tags->flags |= TAG_FLAG_PREV_ERROR;
@@ -1521,7 +1521,7 @@
         line_error (_("`%s' has no Up field (perhaps incorrect sectioning?)"), 
tags->node);
       else if (tags->up)
         {
-          int valid_p = validate (tags->up, tags->line_no, _("Up"));
+          int valid_p = validate (tags->up, tags->line_no, __("Up"));
 
           /* If node X has Up: Y, then warn if Y fails to have a menu item
              or note pointing at X, if Y isn't of the form "(Y)". */
Binärdateien trunk/po/de.gmo and foo/po/de.gmo sind verschieden.

Reply via email to