[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Before l10n, better practices for (message) ?

From: Eli Zaretskii
Subject: Re: Before l10n, better practices for (message) ?
Date: Fri, 26 May 2017 22:00:21 +0300

> From: Yuri Khan <address@hidden>
> Date: Sat, 27 May 2017 01:08:20 +0700
> Cc: Jean-Christophe Helary <address@hidden>, 
>       Emacs developers <address@hidden>
>     (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'?

reply via email to

[Prev in Thread] Current Thread [Next in Thread]