From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Subject: bug#26302: [website] translations Date: Thu, 19 Sep 2019 13:50:10 +0200 Message-ID: <87muf033pp.fsf@gnu.org> References: <20170329154040.ddscahwp2agknihb@abyayala> <8760e8l3bd.fsf@gnu.org> <20170731215448.6zsu2qcfykuzbcd2@abyayala> <20190906142548.4crfjgvxilgalgrs@pelzflorian.localdomain> <87ef0daeqs.fsf@gnu.org> <20190919074829.hu3c7yy3bmeudfsw@florianbeaglebone.fritz.box> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:33426) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAuxj-00055K-9r for bug-guix@gnu.org; Thu, 19 Sep 2019 07:51:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAuxi-0006t1-3L for bug-guix@gnu.org; Thu, 19 Sep 2019 07:51:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:46410) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iAuxh-0006sp-W4 for bug-guix@gnu.org; Thu, 19 Sep 2019 07:51:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iAuxh-0003ju-SN for bug-guix@gnu.org; Thu, 19 Sep 2019 07:51:01 -0400 Sender: "Debbugs-submit" Resent-Message-ID: In-Reply-To: <20190919074829.hu3c7yy3bmeudfsw@florianbeaglebone.fritz.box> (pelzflorian@pelzflorian.de's message of "Thu, 19 Sep 2019 07:48:29 +0000") List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org Sender: "bug-Guix" To: "pelzflorian (Florian Pelz)" Cc: 26302@debbugs.gnu.org Hi, "pelzflorian (Florian Pelz)" skribis: >> > +(define (sgettext x) >> > + "After choosing an identifier for marking s-expressions for >> > +translation, make it usable by defining a macro with it calling >> > +sgettext. If for example the chosen identifier is G_, >> > +use (define-syntax G_ sgettext)." >> > + (syntax-case x () >> > + ((id exp) >> > + (let* ((msgid (sexp->msgid (syntax->datum #'exp))) >> > + (new-exp (deconstruct (syntax->datum #'exp) >> > + (gettext msgid)))) >> > + (datum->syntax #'id new-exp))))) >>=20 >> For this and other similar macros you must use =E2=80=98define-syntax=E2= =80=99, not >> =E2=80=98define=E2=80=99, so that they are defined at expansion time, no= t at run time. > > As per the above docstring, I already have a definition > > (define-syntax G_ sgettext) > > in (apps i18n). Possibly I should just move it here. Hmmm right. It works, but it=E2=80=99s surprising and =E2=80=9Cborderline= =E2=80=9D. If all you want is an alias, I=E2=80=99d recommend writing, say: (define-syntax sgettext =E2=80=A6) (define-syntax G_ (identifier-syntax sgettext)) >> (It doesn=E2=80=99t make any difference when you=E2=80=99re evaluating c= ode since both >> phases run in the same module, but it does make a difference when these >> phases happen at different times, in different processes.) >>=20 >> Consequently, you must arrange for =E2=80=98sexp->msgid=E2=80=99 and =E2= =80=98deconstruct=E2=80=99 to be >> available at expansion time too. This can be done by wrapping their >> definition in =E2=80=98eval-when=E2=80=99: >>=20 >> (eval-when (load expand eval) >> (define (sexp->msgid =E2=80=A6) =E2=80=A6) >> (define (deconstruct =E2=80=A6) =E2=80=A6)) >>=20 >> But actually it=E2=80=99s not clear to me why these are macros. I think= they >> could be regular procedures and it=E2=80=99d work just fine, no? >>=20 > > I do not understand. sexp->msgid and deconstruct are procedures, not > syntax transformers. I can add eval-when, but the current code runs > as expected for me. I tried to explain above but you can check the Guile manual on =E2=80=98eval-when=E2=80=99 (info "(guile) Eval When"). The example there = hopefully clarifies what the problem is. >> > +(define %plural-numbers >> > + ;; Hard-coded list of input numbers such that for each language=E2= =80=99s >> > + ;; plural formula, for each possible output grammatical number, >> > + ;; there is an n among %plural-numbers that yields this output >> > + ;; (cf. section Plural forms in the gettext manual), except 1 is >> > + ;; omitted from this list because it is a special case for >> > + ;; sngettext. That is, calling ngettext with each number from >> > + ;; %plural-numbers and with 1 in any locale is guaranteed to return >> > + ;; each plural form at least once. It would be more resilient >> > + ;; towards new languages if instead of hard-coding we computed this >> > + ;; from the Plural-Forms in the MO file header entry, but that is >> > + ;; not worth the incurred code complexity. >> > + '(0 2 3 11 100)) >>=20 >> I don=E2=80=99t understand this: are these the only plural numbers in all >> languages, or=E2=80=A6? >>=20 > > Yes, in all languages for which a plural=3D formula is documented in the > gettext manual. > > For example, Arabic has > > Plural-Forms: nplurals=3D6; \ > plural=3Dn=3D=3D0 ? 0 : n=3D=3D1 ? 1 : n=3D=3D2 ? 2 : n%100= >=3D3 && n%100<=3D10 ? 3 \ > : n%100>=3D11 ? 4 : 5; > > with input plural numbers 0, 1, 2, 3, 11, 100 mapping to all outputs > 0, 1, 2, 3, 4, 5. > > Maybe I should add this example to the code comment. Oh I see. Maybe just link to the relevant section of the manual ("info (gettext) Plural forms"). I think you can go ahead and push this series to a branch, say =E2=80=98wip-i18n=E2=80=99 (the =E2=80=98wip-=E2=80=99 prefix meaning that = you reserve the right to rebase the branch as you will.) We can then maybe set up a =E2=80=98static-web-site=E2=80=99 service on ber= lin, with appropriate nginx rules, to build and publish the manual at a separate URL so we can all test it. See hydra/berlin.scm in maintenance.git. Thoughts? Thank you! Ludo=E2=80=99.