From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Yuri Khan Newsgroups: gmane.emacs.devel Subject: Re: Before l10n, better practices for (message) ? Date: Sat, 27 May 2017 01:08:20 +0700 Message-ID: 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> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Trace: blaine.gmane.org 1495822166 27359 195.159.176.226 (26 May 2017 18:09:26 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 26 May 2017 18:09:26 +0000 (UTC) Cc: Jean-Christophe Helary , Emacs developers To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri May 26 20:09:21 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 1dEJfr-0006tf-2m for ged-emacs-devel@m.gmane.org; Fri, 26 May 2017 20:09:19 +0200 Original-Received: from localhost ([::1]:37826 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dEJfu-0002vD-Rt for ged-emacs-devel@m.gmane.org; Fri, 26 May 2017 14:09:22 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56822) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dEJfJ-0002tt-70 for emacs-devel@gnu.org; Fri, 26 May 2017 14:08:46 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dEJfI-0002ot-BX for emacs-devel@gnu.org; Fri, 26 May 2017 14:08:45 -0400 Original-Received: from mail-wm0-x232.google.com ([2a00:1450:400c:c09::232]:35035) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dEJfG-0002mA-O4; Fri, 26 May 2017 14:08:42 -0400 Original-Received: by mail-wm0-x232.google.com with SMTP id b84so1106849wmh.0; Fri, 26 May 2017 11:08:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=0xweJMi9bOtnVACKYxZMmJYnR6+WMx1OwMAc/gammq4=; b=KT4L5WNgXEgMgATmA1NfbgroPa6z1hu3j0Q01rBMDxxU/Poq8gyG/yUdOyvnkLBpEQ xfyelyNLaR0mvS5ZsTtnSH1UpSvHv4YL3NyRruWNiHBAsA0LQdkVnGjIPOBufDmNv0OL kk7AX6aNBF9mVtCuRtLrt8/5sMKm+P+doPVNULJ/Qq95AT8BofVf54cfCFOIOaQKcZF5 gzZZXncppay1OuOyUji7iSkfUj/oPzE7yWrHFMNxPfFtt7YUXHcLtveizVXTb8zEVd6Y DmtXKDyhwXqsxK4S7Q6sf+6ZYhR40KnA//zTD5D7lSsRxwudp5pRvwgjNQttU+5z4tXw 430A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=0xweJMi9bOtnVACKYxZMmJYnR6+WMx1OwMAc/gammq4=; b=paTeDhccPqQ/IDnOkFZDXRHLFWwbd37pkDOn8A/NEEuIBHFKNRLR7u/sA6LmyFXArT djleIqjA2sDCz7sExT+jvgImoJxNnZWwwPf3Bwl12W3u40rrX2YJ5AhA/uwSvWHylrOh Q+BV5UbJIqqF3qHpaL59XMJ8N+wTuMFiuKPI/c+47iHDB7AR9k1Xy4bUJA6sYmd/VU/p xdpoY7bAuJZMErbXs2h2VTWHUN3Sgh5Bib/XxrGRVBjWtpRXY3eP7V9YO1c1U68Ej66K 6/+mP5iriKKDs2BmxCqhhT7BpimrzQEjLcQW4edTWieplyEmax9aPVoxHsePFGKnq8qH qfHQ== X-Gm-Message-State: AODbwcB5p5415h2KC7k0AZc8wxTSya3FLHyITDkSrEkk4ZsFe6bI+BDf Z9XZHa5vVMMgGOnGyxXZlUSlS7BARins X-Received: by 10.28.22.12 with SMTP id 12mr13595605wmw.97.1495822121402; Fri, 26 May 2017 11:08:41 -0700 (PDT) Original-Received: by 10.223.163.196 with HTTP; Fri, 26 May 2017 11:08:20 -0700 (PDT) In-Reply-To: <83bmqfk785.fsf@gnu.org> X-Google-Sender-Auth: tbLXl3gmRDttusJvBNyX2uXbE6s X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::232 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:215229 Archived-At: On Fri, May 26, 2017 at 9:44 PM, Eli Zaretskii wrote: >> Is it very different from global variables clashing or not between packages? > > No. But the need to name messages with package qualifiers is a > significant nuisance, and will fill the "namespace" of a file with > many symbols. Messages do not have to be global variables. They could be retrieved by a helper function accepting a package namespace and a message key. In gettext, this function is dgettext. (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))