From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.devel Subject: Re: Emacs i18n Date: Mon, 25 Mar 2019 15:31:14 -0700 Organization: UCLA Computer Science Department Message-ID: References: <87o97aq6gz.fsf@jidanni.org> <87tvgoud56.fsf@mail.linkov.net> <83o96wk2mi.fsf@gnu.org> <87k1hjfvjd.fsf@mail.linkov.net> <871s3p0zdz.fsf@mail.linkov.net> <83h8ckezyt.fsf@gnu.org> <87h8cjspc0.fsf@mail.linkov.net> <29a53a39-fa50-1e94-9420-a3ea1250aa44@gmail.com> <87r2azq478.fsf@mail.linkov.net> <83o963s4gx.fsf@gnu.org> <87va09ckym.fsf@mail.linkov.net> <83sgvdndt0.fsf@gnu.org> <8736ncgcnm.fsf@mail.linkov.net> <5F95E50C-2A55-4ED2-A82B-86FAAFC526ED@gmail.com> <87ef6uod20.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------A1E56A7A46C5DEE658F92830" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="228030"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.0 Cc: Jean-Christophe Helary , Emacs developers To: Juri Linkov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Mar 25 23:45:17 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h8YLE-000x9X-6A for ged-emacs-devel@m.gmane.org; Mon, 25 Mar 2019 23:45:16 +0100 Original-Received: from localhost ([127.0.0.1]:49563 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h8YLD-0002KQ-7T for ged-emacs-devel@m.gmane.org; Mon, 25 Mar 2019 18:45:15 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:52970) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h8YJ4-0000RN-R8 for emacs-devel@gnu.org; Mon, 25 Mar 2019 18:43:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h8Y7i-00016G-Ac for emacs-devel@gnu.org; Mon, 25 Mar 2019 18:31:19 -0400 Original-Received: from zimbra.cs.ucla.edu ([131.179.128.68]:56202) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h8Y7h-00015h-Rr for emacs-devel@gnu.org; Mon, 25 Mar 2019 18:31:18 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 1ECC0160D78; Mon, 25 Mar 2019 15:31:16 -0700 (PDT) Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 2T82JFGtbppI; Mon, 25 Mar 2019 15:31:14 -0700 (PDT) Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id C6198160D8D; Mon, 25 Mar 2019 15:31:14 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id mG80XkeEn-ZN; Mon, 25 Mar 2019 15:31:14 -0700 (PDT) Original-Received: from Penguin.CS.UCLA.EDU (Penguin.CS.UCLA.EDU [131.179.64.200]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id A7DE7160D04; Mon, 25 Mar 2019 15:31:14 -0700 (PDT) Openpgp: preference=signencrypt Autocrypt: addr=eggert@cs.ucla.edu; prefer-encrypt=mutual; keydata= xsFNBEyAcmQBEADAAyH2xoTu7ppG5D3a8FMZEon74dCvc4+q1XA2J2tBy2pwaTqfhpxxdGA9 Jj50UJ3PD4bSUEgN8tLZ0san47l5XTAFLi2456ciSl5m8sKaHlGdt9XmAAtmXqeZVIYX/UFS 96fDzf4xhEmm/y7LbYEPQdUdxu47xA5KhTYp5bltF3WYDz1Ygd7gx07Auwp7iw7eNvnoDTAl KAl8KYDZzbDNCQGEbpY3efZIvPdeI+FWQN4W+kghy+P6au6PrIIhYraeua7XDdb2LS1en3Ss mE3QjqfRqI/A2ue8JMwsvXe/WK38Ezs6x74iTaqI3AFH6ilAhDqpMnd/msSESNFt76DiO1ZK QMr9amVPknjfPmJISqdhgB1DlEdw34sROf6V8mZw0xfqT6PKE46LcFefzs0kbg4GORf8vjG2 Sf1tk5eU8MBiyN/bZ03bKNjNYMpODDQQwuP84kYLkX2wBxxMAhBxwbDVZudzxDZJ1C2VXujC OJVxq2kljBM9ETYuUGqd75AW2LXrLw6+MuIsHFAYAgRr7+KcwDgBAfwhPBYX34nSSiHlmLC+ KaHLeCLF5ZI2vKm3HEeCTtlOg7xZEONgwzL+fdKo+D6SoC8RRxJKs8a3sVfI4t6CnrQzvJbB n6gxdgCu5i29J1QCYrCYvql2UyFPAK+do99/1jOXT4m2836j1wARAQABzSBQYXVsIEVnZ2Vy dCA8ZWdnZXJ0QGNzLnVjbGEuZWR1PsLBfgQTAQIAKAUCTIByZAIbAwUJEswDAAYLCQgHAwIG FQgCCQoLBBYCAwECH In-Reply-To: <87ef6uod20.fsf@mail.linkov.net> Content-Language: en-US X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 131.179.128.68 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:234734 Archived-At: This is a multi-part message in MIME format. --------------A1E56A7A46C5DEE658F92830 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 3/25/19 2:32 PM, Juri Linkov wrote: > I don't know where to put i18n related code, so since ngettext should > have C calls anyway, I moved it to editfns.c near the function =E2=80=98= message=E2=80=99 > where it still just returns the correct plurals without doing any trans= lation. That stub had some problems: 1. It lacked documentation in the Elisp manual. Important changes like this should be documented -- to some extent the documentation is even more important than the code. Can you write something? 2. While you're thinking about (1) here are some other questions. How will ngettext determine the message catalog? Is the catalog visible to users as a global variable, or as a hidden part of the global state, or is it something explicit? How will catalogs from multiple packages be used? How would a multi-lingual application work in Emacs if the message catalog is part of global state? This seems to be a crucial issue, I'd say. For example, should Emacs export dcngettext to Lisp code, instead of just plain ngettext? (Emacs could then define ngettext in terms of dcngettext.) 3. User C code is not supposed to inspect the _LIBC macro; that's for glibc internal use. In Emacs _LIBC should be used only with code shared with glibc, and we should assume _LIBC is never defined when files are compiled for Emacs. 4. The stub doesn't work with bignums. 5. When calling the C-level ngettext, strings are not properly recoded. I fixed (3) and (4), and temporarily worked around (5), by installing the attached patch. To do a better job with (2) and (5) please see the gettext manual's instructions for package maintainers, here: https://www.gnu.org/software/gettext/manual/gettext.html#Maintainers To my mind (1) and (2) are the most-pressing problems. --------------A1E56A7A46C5DEE658F92830 Content-Type: text/x-patch; name="0001-Port-recent-ngettext-stub-to-non-glibc.patch" Content-Disposition: attachment; filename="0001-Port-recent-ngettext-stub-to-non-glibc.patch" Content-Transfer-Encoding: quoted-printable >From a361c54b8339ad79f65e924c4a1f7bbcdb1859e2 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 25 Mar 2019 15:20:20 -0700 Subject: [PATCH] Port recent ngettext stub to non-glibc MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit * src/editfns.c: Don=E2=80=99t try to call glibc ngettext; we=E2=80=99re not ready for that yet. (Fngettext): Do not restrict integer arguments to fixnums. Improve doc string a bit. --- src/editfns.c | 34 +++++++++------------------------- 1 file changed, 9 insertions(+), 25 deletions(-) diff --git a/src/editfns.c b/src/editfns.c index ab48cdb6fd..bfffadc733 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -53,12 +53,6 @@ along with GNU Emacs. If not, see . */ #include "window.h" #include "blockinput.h" =20 -#ifdef _LIBC -# include -#else -# include "gettext.h" -#endif - static void update_buffer_properties (ptrdiff_t, ptrdiff_t); static Lisp_Object styled_format (ptrdiff_t, Lisp_Object *, bool); =20 @@ -2845,30 +2839,20 @@ usage: (save-restriction &rest BODY) */) /* i18n (internationalization). */ =20 DEFUN ("ngettext", Fngettext, Sngettext, 3, 3, 0, - doc: /* Return the plural form of the translation of the string. -This function is similar to the `gettext' function as it finds the messa= ge -catalogs in the same way. But it takes two extra arguments. The MSGID -parameter must contain the singular form of the string to be converted. -It is also used as the key for the search in the catalog. -The MSGID_PLURAL parameter is the plural form. The parameter N is used -to determine the plural form. If no message catalog is found MSGID is -returned if N is equal to 1, otherwise MSGID_PLURAL. */) + doc: /* Return the translation of MSGID (plural MSGID_PLURAL) dep= ending on N. +MSGID is the singular form of the string to be converted; +use it as the key for the search in the translation catalog. +MSGID_PLURAL is the plural form. Use N to select the proper translation= . +If no message catalog is found, MSGID is returned if N is equal to 1, +otherwise MSGID_PLURAL. */) (Lisp_Object msgid, Lisp_Object msgid_plural, Lisp_Object n) { CHECK_STRING (msgid); CHECK_STRING (msgid_plural); - CHECK_FIXNUM (n); + CHECK_INTEGER (n); =20 -#ifdef _LIBGETTEXT_H - return build_string (ngettext (SSDATA (msgid), - SSDATA (msgid_plural), - XFIXNUM (n))); -#else - if (XFIXNUM (n) =3D=3D 1) - return msgid; - else - return msgid_plural; -#endif + /* Placeholder implementation until we get our act together. */ + return EQ (n, make_fixnum (1)) ? msgid : msgid_plural; } =0C DEFUN ("message", Fmessage, Smessage, 1, MANY, 0, --=20 2.20.1 --------------A1E56A7A46C5DEE658F92830--