On Die, 07 Mär 2006, preining wrote:
> Short description: makeinfo: locale settings should not influence output
> files

Here is an updated patch including Svens fixed locale hack and Karls
xstrdup vs strdup.

Still missing: Setting the interface_language global variable from the
cm_documentlanguage function.

This needs a match from de to de_DE etc.

But I will include this patch as is in the next version of the texinfo
Debian packages.

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
-------------------------------------------------------------------------------
FINUGE (vb.)
In any division of foodstuffs equally between several people, to give
yourself the extra slice left over.
                        --- Douglas Adams, The Meaning of Liff
diff -urN trunk/makeinfo/defun.c foo/makeinfo/defun.c
--- trunk/makeinfo/defun.c      2006-02-16 13:03:48.000000000 +0100
+++ foo/makeinfo/defun.c        2006-03-08 01:23:34.000000000 +0100
@@ -400,28 +400,28 @@
     {
     case defun:
     case deftypefun:
-      category = _("Function");
+      category = __("Function");
       break;
     case defmac:
-      category = _("Macro");
+      category = __("Macro");
       break;
     case defspec:
-      category = _("Special Form");
+      category = __("Special Form");
       break;
     case defvar:
     case deftypevar:
-      category = _("Variable");
+      category = __("Variable");
       break;
     case defopt:
-      category = _("User Option");
+      category = __("User Option");
       break;
     case defivar:
     case deftypeivar:
-      category = _("Instance Variable");
+      category = __("Instance Variable");
       break;
     case defmethod:
     case deftypemethod:
-      category = _("Method");
+      category = __("Method");
       break;
     default:
       category = next_nonwhite_defun_arg (&scan_args);
@@ -497,24 +497,24 @@
         execute_string (" --- %s: %s %s", category, type_name, defined_name);
         break;
       case defcv:
-        execute_string (" --- %s %s %s: %s", category, _("of"), type_name,
+        execute_string (" --- %s %s %s: %s", category, __("of"), type_name,
                         defined_name);
         break;
       case deftypecv:
       case deftypeivar:
-        execute_string (" --- %s %s %s: %s %s", category, _("of"), type_name,
+        execute_string (" --- %s %s %s: %s %s", category, __("of"), type_name,
                         type_name2, defined_name);
         break;
       case defop:
-        execute_string (" --- %s %s %s: %s", category, _("on"), type_name,
+        execute_string (" --- %s %s %s: %s", category, __("on"), type_name,
                         defined_name);
         break;
       case deftypeop:
-        execute_string (" --- %s %s %s: %s %s", category, _("on"), type_name,
+        execute_string (" --- %s %s %s: %s %s", category, __("on"), type_name,
                         type_name2, defined_name);
         break;
       case deftypemethod:
-        execute_string (" --- %s %s %s: %s %s", category, _("on"), type_name,
+        execute_string (" --- %s %s %s: %s %s", category, __("on"), type_name,
                         type_name2, defined_name);
         break;
       }
@@ -542,13 +542,13 @@
         case defcv:
         case deftypecv:
         case deftypeivar:
-         execute_string ("--- %s %s %s: ", category, _("of"), type_name);
+         execute_string ("--- %s %s %s: ", category, __("of"), type_name);
          break;
 
         case defop:
         case deftypemethod:
         case deftypeop:
-         execute_string ("--- %s %s %s: ", category, _("on"), type_name);
+         execute_string ("--- %s %s %s: ", category, __("on"), type_name);
          break;
        } /* switch (base_type)... */
 
@@ -641,13 +641,13 @@
        execute_string ("@vindex %s\n", defined_name);
        break;
       case deftypeivar:
-       execute_string ("@vindex %s %s %s\n", defined_name, _("of"),
+       execute_string ("@vindex %s %s %s\n", defined_name, __("of"),
                         type_name);
        break;
       case defop:
       case deftypeop:
       case deftypemethod:
-       execute_string ("@findex %s %s %s\n", defined_name, _("on"),
+       execute_string ("@findex %s %s %s\n", defined_name, __("on"),
                         type_name);
        break;
       case deftp:
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-08 04:58:35.000000000 +0100
@@ -33,6 +33,9 @@
 /* Current language code; default is English.  */
 language_code_type language_code = en;
 
+/* interface_language. */
+char *interface_language = "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-08 01:18:42.000000000 +0100
@@ -145,4 +145,6 @@
 
 extern char *current_document_encoding (void);
 
+extern char *interface_language;
+
 #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-10 02:05:29.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 */
+         interface_language = xstrdup(optarg);
+         break;
+
         case 'i':
           if (sscanf (optarg, "%d", &xml_indentation_increment) != 1)
             {
@@ -1670,7 +1678,7 @@
 
   /* html fixxme: should output this as trailer on first page.  */
   if (!no_headers && !html && !xml)
-    add_word_args (_("This is %s, produced by makeinfo version %s from %s.\n"),
+    add_word_args (__("This is %s, produced by makeinfo version %s from 
%s.\n"),
                    output_filename, VERSION, input_filename);
 
   close_paragraph ();
@@ -4155,3 +4163,16 @@
     }
   return 0;
 }
+
+char *
+getdocumenttext (const char *msgid)
+{
+  char *old_locale, *save_locale;
+  char *s;
+  old_locale = setlocale(LC_ALL, NULL);
+  save_locale = xstrdup(old_locale);
+  setlocale(LC_ALL, interface_language);
+  s = gettext(msgid);
+  setlocale(LC_ALL, save_locale);
+  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)". */
diff -urN trunk/makeinfo/toc.c foo/makeinfo/toc.c
--- trunk/makeinfo/toc.c        2006-02-16 13:03:48.000000000 +0100
+++ foo/makeinfo/toc.c  2006-03-08 01:23:58.000000000 +0100
@@ -194,7 +194,7 @@
       /* no, so return to sender ;-) */
       return;
 
-  add_html_block_elt_args ("\n<div class=\"contents\">\n<h2>%s</h2>\n<ul>\n", 
_("Table of Contents"));
+  add_html_block_elt_args ("\n<div class=\"contents\">\n<h2>%s</h2>\n<ul>\n", 
__("Table of Contents"));
 
   last_level = toc_entry_alist[0]->level;
 
@@ -268,9 +268,9 @@
   if (!toc_counter)
       return;
 
-  insert_string ((char *) _("Table of Contents"));
+  insert_string ((char *) __("Table of Contents"));
   insert ('\n');
-  for (i = 0; i < strlen (_("Table of Contents")); i++)
+  for (i = 0; i < strlen (__("Table of Contents")); i++)
     insert ('*');
   insert_string ("\n\n");
 
@@ -301,7 +301,7 @@
   if (!toc_counter)
     return;
 
-  add_html_block_elt_args ("\n<div 
class=\"shortcontents\">\n<h2>%s</h2>\n<ul>\n", _("Short Contents"));
+  add_html_block_elt_args ("\n<div 
class=\"shortcontents\">\n<h2>%s</h2>\n<ul>\n", __("Short Contents"));
 
   if (contents_filename)
     toc_file = filename_part (contents_filename);
@@ -334,9 +334,9 @@
   if (!toc_counter)
       return;
 
-  insert_string ((char *) _("Short Contents"));
+  insert_string ((char *) __("Short Contents"));
   insert ('\n');
-  for (i = 0; i < strlen (_("Short Contents")); i++)
+  for (i = 0; i < strlen (__("Short Contents")); i++)
     insert ('*');
   insert_string ("\n\n");
 
diff -urN trunk/makeinfo/xref.c foo/makeinfo/xref.c
--- trunk/makeinfo/xref.c       2006-02-16 13:03:48.000000000 +0100
+++ foo/makeinfo/xref.c 2006-03-08 01:24:59.000000000 +0100
@@ -131,7 +131,7 @@
         {
           if (!ref_flag)
             add_word (px_ref_flag || printing_index
-                ? (char *) _("see ") : (char *) _("See "));
+                ? (char *) __("see ") : (char *) __("See "));
 
           if (!*arg4 && !*arg5)
             {
@@ -155,7 +155,7 @@
             }
           else if (*arg5)
             {
-              add_word_args (_("See section ``%s'' in "), *arg3 ? arg3 : arg1);
+              add_word_args (__("See section ``%s'' in "), *arg3 ? arg3 : 
arg1);
               xml_insert_element (CITE, START);
               add_word (arg5);
               xml_insert_element (CITE, END);
@@ -168,7 +168,7 @@
       else if (xml)
         {
           if (!ref_flag)
-            add_word_args ("%s", px_ref_flag ? _("see ") : _("See "));
+            add_word_args ("%s", px_ref_flag ? __("see ") : __("See "));
 
           xml_insert_element (XREF, START);
           xml_insert_element (XREFNODENAME, START);
@@ -203,7 +203,7 @@
       else if (html)
         {
           if (!ref_flag)
-            add_word_args ("%s", px_ref_flag ? _("see ") : _("See "));
+            add_word_args ("%s", px_ref_flag ? __("see ") : __("See "));
         }
       else
         add_word_args ("%s", px_ref_flag ? "*note " : "*Note ");
@@ -453,7 +453,7 @@
         {
           char *tem;
 
-          add_word ((char *) _("see "));
+          add_word ((char *) __("see "));
           /* html fixxme: revisit this */
           add_html_elt ("<a href=");
           if (splitting)

Reply via email to