From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Before l10n, better practices for (message) ? Date: Fri, 26 May 2017 22:00:21 +0300 Message-ID: <831srbjvei.fsf@gnu.org> References: <2623E5C5-4D40-4C9F-BFF6-181D2E69F984@gmail.com> <831srgnuyc.fsf@gnu.org> <83vaormn2x.fsf@gnu.org> <1B4DE39C-E293-4370-9E76-82E1B7385C00@gmail.com> <83o9ugjaqd.fsf@gnu.org> <83bmqfk785.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1495825265 32654 195.159.176.226 (26 May 2017 19:01:05 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 26 May 2017 19:01:05 +0000 (UTC) Cc: jean.christophe.helary@gmail.com, emacs-devel@gnu.org To: Yuri Khan Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri May 26 21:00:58 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dEKTp-0008Is-0T for ged-emacs-devel@m.gmane.org; Fri, 26 May 2017 21:00:57 +0200 Original-Received: from localhost ([::1]:37996 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dEKTu-0005Wl-K6 for ged-emacs-devel@m.gmane.org; Fri, 26 May 2017 15:01:02 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40460) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dEKTL-0005We-H7 for emacs-devel@gnu.org; Fri, 26 May 2017 15:00:28 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dEKTI-0004Uz-EO for emacs-devel@gnu.org; Fri, 26 May 2017 15:00:27 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:48588) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dEKTI-0004Uv-Ax; Fri, 26 May 2017 15:00:24 -0400 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:1262 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1dEKTH-0003bm-Ff; Fri, 26 May 2017 15:00:23 -0400 In-reply-to: (message from Yuri Khan on Sat, 27 May 2017 01:08:20 +0700) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e 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:215233 Archived-At: > From: Yuri Khan > Date: Sat, 27 May 2017 01:08:20 +0700 > Cc: Jean-Christophe Helary , > Emacs developers > > (require 'gettext) > > (message (dgettext "hello" "Hello World!")) > > Gettext also has a helper function named gettext and aliased _, which > use the domain set by an earlier invocation of textdomain(). In Elisp, > it seems most natural to express that like this: > > (defun hello-_ (key) > (dgettext "hello" key)) > (message (hello-_ "Hello World!")) > > The function hello-_ would be defined once in the hello package and > then used throughout it. Another package would define its own wrapper > around dgettext, with a different domain. > > > Inside, dgettext could consult a two-level hashtable, first keyed by > domain, second by key. Alternatively, a domain could be a hashtable > variable; in the latter case: > > ;; in hello.el > (defvar hello-domain nil) > (defun hello-_ (key) > (dgettext hello-domain key)) > (message (hello-_ "Hello World!")) > > ;; in gettext.el > (defun dgettext (domain key) > (gethash key domain key)) Why not hide all this ugliness inside 'message'?