From mboxrd@z Thu Jan 1 00:00:00 1970 From: "pelzflorian (Florian Pelz)" Subject: bug#26302: [website] translations Date: Thu, 19 Sep 2019 22:08:28 +0000 Message-ID: <20190919220828.voohijutgmi6sd3w@florianbeaglebone.fritz.box> References: <20170329154040.ddscahwp2agknihb@abyayala> <8760e8l3bd.fsf@gnu.org> <20170731215448.6zsu2qcfykuzbcd2@abyayala> <20190906142548.4crfjgvxilgalgrs@pelzflorian.localdomain> <87ef0daeqs.fsf@gnu.org> <20190919074829.hu3c7yy3bmeudfsw@florianbeaglebone.fritz.box> <87muf033pp.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="gyhfxphw2bppya2p" Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:59507) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iB4bo-0007xL-Sp for bug-guix@gnu.org; Thu, 19 Sep 2019 18:09:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iB4bn-0002kS-9H for bug-guix@gnu.org; Thu, 19 Sep 2019 18:09:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:47728) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iB4bm-0002i7-J1 for bug-guix@gnu.org; Thu, 19 Sep 2019 18:09:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iB4bm-0002FE-BS for bug-guix@gnu.org; Thu, 19 Sep 2019 18:09:02 -0400 Sender: "Debbugs-submit" Resent-Message-ID: Content-Disposition: inline In-Reply-To: <87muf033pp.fsf@gnu.org> 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: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 26302@debbugs.gnu.org --gyhfxphw2bppya2p Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable The branch wip-i18n is pushed now. On Thu, Sep 19, 2019 at 01:50:10PM +0200, Ludovic Court=C3=A8s wrote: > Hi, >=20 > "pelzflorian (Florian Pelz)" skribis: >=20 > >> > +(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, = not 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. >=20 > Hmmm right. It works, but it=E2=80=99s surprising and =E2=80=9Cborderlin= e=E2=80=9D. >=20 > If all you want is an alias, Yes, an alias is what I wanted, like gettext. > I=E2=80=99d recommend writing, say: >=20 > (define-syntax sgettext =E2=80=A6) > (define-syntax G_ > (identifier-syntax sgettext)) >=20 This breaks the code, I think because the sgettext result gets evaluated in a clean environment which lacks surrounding variables. For example, (let ((i 5) (G_ `("There are " ,i " apples")))) fails to resolve i. I have left this borderline code as it is. > >> (It doesn=E2=80=99t make any difference when you=E2=80=99re evaluating= code 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 thi= nk 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. >=20 > 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 ther= e hopefully > clarifies what the problem is. > I had read that Guile manual section, but it is hard to understand when eval-when is needed and when it is not needed, because the manual=E2=80=99s negative example for wrong code runs just as fine for me as the eval-when version, even when saved to a separate module. I have not used eval-when for now. > >> > +(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 retu= rn > >> > + ;; each plural form at least once. It would be more resilient > >> > + ;; towards new languages if instead of hard-coding we computed th= is > >> > + ;; 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%1= 00>=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. >=20 > Oh I see. Maybe just link to the relevant section of the manual ("info > (gettext) Plural forms"). > I made the reference more clear in the %plural-forms comment now. > [=E2=80=A6] > We can then maybe set up a =E2=80=98static-web-site=E2=80=99 service on b= erlin, 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. >=20 > Thoughts? >=20 I=E2=80=99ll leave this to you. :) Regards, Florian --gyhfxphw2bppya2p Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEzvTLkUhWujgKIKfiMAiIyznGOBcFAl2D/FUACgkQMAiIyznG OBfcEAf/dQDz/sQ3per0SfQ9/BbZtWX8zq2XPZzDCPQuIqOQki4gOZzi/181T8x9 1agtLzhgiJLW6NmLmHyOchYZO3MLKUBSgjcQOs6mD+wMwkc1o/rjaiKy+EuOUaVN 37T0yKrnM7dSMuRim+iRpREkZHf/q0/KcglbXaEQHm6O0Qpp8ikLORhQkPlSpe3o nTJLSODcwkLOIkdhYx8sCLZf5Y46PYk7Rg26CM7ssG+0djQER0uEiye4D9Vno7nD PfK707UAh97hdCnrQv2mgWYl3iOo7We+KIX30X3RExJY/tYgIKMMhmDb2ss2C9KF 5olG81ug7D9PbdtMG6xb51zO+pFsRw== =Lmyr -----END PGP SIGNATURE----- --gyhfxphw2bppya2p--