Gnus development mailing list
 help / color / mirror / Atom feed
From: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
Subject: Re: Internationalization
Date: 12 Nov 1996 23:45:36 +0100	[thread overview]
Message-ID: <m2vibbc4q7.fsf@proletcult.ifi.uio.no> (raw)
In-Reply-To: David Moore's message of 11 Nov 1996 14:19:59 -0800

Perhaps this patch is a bit better.  It avoids creating garbage
strings when performing identity translations.  I've also moved it to
doc.c, which seemed a nicer place.  

`documentation' now runs all strings through `translate-string', so
xgettext for Elisp files should snarf both the `_' forms and all
documentation strings for interactive functions.  Probably.

*** doc.c.~1~	Wed Apr 10 00:08:50 1996
--- doc.c	Tue Nov 12 23:40:02 1996
***************
*** 36,41 ****
--- 36,46 ----
  #define O_RDONLY 0
  #endif
  
+ #define USE_GETTEXT 
+ #ifdef USE_GETTEXT
+ #include <libintl.h>
+ #endif
+ 
  #include "lisp.h"
  #include "buffer.h"
  #include "keyboard.h"
***************
*** 335,341 ****
        doc = Fsubstitute_command_keys (doc);
        UNGCPRO;
      }
!   return doc;
  }
  
  DEFUN ("documentation-property", Fdocumentation_property, Sdocumentation_property, 2, 3, 0,
--- 340,346 ----
        doc = Fsubstitute_command_keys (doc);
        UNGCPRO;
      }
!   return Ftranslate_string (doc);
  }
  
  DEFUN ("documentation-property", Fdocumentation_property, Sdocumentation_property, 2, 3, 0,
***************
*** 688,693 ****
--- 693,779 ----
    xfree (buf);
    RETURN_UNGCPRO (tem);
  }
+ 
+ 
+ \f
+ DEFUN ("translate-string", Ftranslate_string, Stranslate_string, 1, 1, "sTranslate string: ",
+        "Translate STRING using gettext.")
+      (string)
+      Lisp_Object string;
+ {
+   char *trans;
+   CHECK_STRING (string, 0);
+ 
+ #ifdef USE_GETTEXT
+   trans = gettext (XSTRING (string)->data);
+   /* Check whether the translation returned a new string.  If not,
+      just return the old string.  This avoids creating garbage strings. */
+   if (strcmp (XSTRING (string)->data, trans))
+     return build_string (trans);
+   else
+     return string;
+ #else
+   return string;
+ #endif
+ }
+ 
+ DEFUN ("set-translation-domain", Fset_translation_domain, Sset_translation_domain, 1, 1, 0,
+        "Set the current translation domain to STRING.")
+      (string)
+      Lisp_Object string;
+ {
+   CHECK_STRING (string, 0);
+ 
+ #ifdef USE_GETTEXT
+   textdomain (XSTRING (string)->data);
+   return string;
+ #else
+   return Qnil;
+ #endif
+ }
+ 
+ DEFUN ("get-translation-domain", Fget_translation_domain, Sget_translation_domain, 0, 0, 0,
+        "Return the current translation domain.")
+      ()
+ {
+ #ifdef USE_GETTEXT
+   return build_string (textdomain (NULL));
+ #else
+   return Qnil;
+ #endif
+ }
+ 
+ DEFUN ("set-translation-directory", Fset_translation_directory, Sset_translation_directory, 1, 1, 0,
+        "Set the current translation directory to STRING.")
+      (string)
+      Lisp_Object string;
+ {
+   CHECK_STRING (string, 0);
+ 
+ #ifdef USE_GETTEXT
+   bindtextdomain (textdomain (NULL), XSTRING (string)->data);
+   return string;
+ #else
+   return Qnil;
+ #endif
+ }
+ 
+ DEFUN ("get-translation-directory", Fget_translation_directory, Sget_translation_directory, 0, 0, 0,
+        "Return the current translation directory.")
+      ()
+ {
+   char *dir;
+ #ifdef USE_GETTEXT
+   if (dir = bindtextdomain (textdomain (NULL), NULL))
+     return build_string (dir);
+   else
+     return Qnil;
+ #else
+   return Qnil;
+ #endif
+ }
+ 
+ 
  \f
  syms_of_doc ()
  {
***************
*** 699,702 ****
--- 785,794 ----
    defsubr (&Sdocumentation_property);
    defsubr (&Ssnarf_documentation);
    defsubr (&Ssubstitute_command_keys);
+ 
+   defsubr (&Stranslate_string);
+   defsubr (&Sget_translation_domain);
+   defsubr (&Sset_translation_domain);
+   defsubr (&Sget_translation_directory);
+   defsubr (&Sset_translation_directory);
  }

-- 
(domestic pets only, the antidote for overdose, milk.)
  larsi@ifi.uio.no * Lars Ingebrigtsen


  reply	other threads:[~1996-11-12 22:45 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-11-10 15:31 Internationalization Lars Magne Ingebrigtsen
1996-11-10 17:05 ` Internationalization Andy Eskilsson
1996-11-10 17:51   ` Internationalization Kai Grossjohann
1996-11-10 19:02 ` Internationalization David Kågedal
1996-11-11  6:27   ` Internationalization Steinar Bang
1996-11-11 15:20   ` Internationalization Lars Magne Ingebrigtsen
1996-11-11  0:25 ` Internationalization visigoth
1996-11-11 15:25   ` Internationalization Lars Magne Ingebrigtsen
1996-11-11 22:19     ` Internationalization David Moore
1996-11-12 22:45       ` Lars Magne Ingebrigtsen [this message]
1996-11-11 12:14 ` Internationalization Robert Bihlmeyer
1996-11-11 12:50 ` Internationalization Per Abrahamsen
1996-11-11 15:14   ` Internationalization William Perry
1996-11-11 15:24     ` Internationalization Per Abrahamsen
1996-11-11 22:01   ` Internationalization François Pinard
1996-11-12 10:58     ` Internationalization Per Abrahamsen
1996-11-12 15:59       ` Internationalization François Pinard
1996-11-12 16:57         ` Internationalization Ulrich Drepper
     [not found]           ` <rjwwvqgxz1.fsf@babbage.dina.kvl.dk>
     [not found]             ` <x7ralyf6rx.fsf@myware.rz.uni-karlsruhe.de>
     [not found]               ` <rj3eydhwx5.fsf@babbage.dina.kvl.dk>
1996-11-14 12:28                 ` Internationalization François Pinard
1996-11-12 22:07         ` Internationalization Lars Magne Ingebrigtsen
1996-11-13 19:19           ` Internationalization Jan Vroonhof
1996-11-13 22:05             ` Internationalization William Perry
1996-11-14 19:27               ` Internationalization Ralph Schleicher
1996-11-12 20:12   ` Internationalization Jan Vroonhof
1996-11-11 21:35 ` Internationalization François Pinard
1996-11-12  1:57   ` Internationalization Ulrich Drepper
1996-11-12 19:56   ` Internationalization Lars Magne Ingebrigtsen
1996-11-12 22:40     ` Internationalization Ulrich Drepper
2002-10-20 21:21     ` Internationalization François Pinard
1996-11-17 22:59 ` Internationalization Ralph Schleicher

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2vibbc4q7.fsf@proletcult.ifi.uio.no \
    --to=larsi@ifi.uio.no \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).