From mboxrd@z Thu Jan 1 00:00:00 1970 From: "pelzflorian (Florian Pelz)" Subject: bug#26302: [website] translations Date: Thu, 19 Sep 2019 07:48:29 +0000 Message-ID: <20190919074829.hu3c7yy3bmeudfsw@florianbeaglebone.fritz.box> References: <20170329154040.ddscahwp2agknihb@abyayala> <8760e8l3bd.fsf@gnu.org> <20170731215448.6zsu2qcfykuzbcd2@abyayala> <20190906142548.4crfjgvxilgalgrs@pelzflorian.localdomain> <87ef0daeqs.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="wxpibp5tboksjfbf" Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:58262) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iArBX-0004gs-KK for bug-guix@gnu.org; Thu, 19 Sep 2019 03:49:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iArBW-00086w-GB for bug-guix@gnu.org; Thu, 19 Sep 2019 03:49:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:46268) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iArBW-00086o-5t for bug-guix@gnu.org; Thu, 19 Sep 2019 03:49:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iArBW-0001wZ-2i for bug-guix@gnu.org; Thu, 19 Sep 2019 03:49:02 -0400 Sender: "Debbugs-submit" Resent-Message-ID: Content-Disposition: inline In-Reply-To: <87ef0daeqs.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: GNU Guix maintainers , 26302@debbugs.gnu.org --wxpibp5tboksjfbf Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Sep 18, 2019 at 03:57:47PM +0200, Ludovic Court=C3=A8s wrote: > Hi Florian, >=20 > Could you create an account on Savannah so we can give you commit > access? >=20 Done. My username is pelzflorian. > > +(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. > (It doesn=E2=80=99t make any difference when you=E2=80=99re evaluating co= de 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. > > +(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. Regards, Florian --wxpibp5tboksjfbf Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEzvTLkUhWujgKIKfiMAiIyznGOBcFAl2DMsQACgkQMAiIyznG OBdwMQf/Z4wLkn/4STj/7S08bRf9dIa8ksRXrAJ1wgJgkvXEkkLz9QBEH9RSF+WY 0EJgUwcRNMG7va+Knxb7ISwarDuRdTOP5zD8aAvEyVHzDUCut/kUDn1Fj7DEpoD/ 9JVWRBNMhmpZ7oTYD1olktB6yci8nHZDJIQL16d8OJ8BDRhD+80X6ECpbNSULALC uFdgUSEdiA7raBrzH9+ahhfyMwu6powhPvP8kXJQ6eRG4AZQrOwwIOkp26mUlnej P4kgKTtovrrWHJVNofkRbUiQoSacxVZnSuGgFboUP8+l5JK2eJ6XwOweG7mbp2Yv md/AA+VgzHAZF9oIeWpaPcKdlPOEfw== =m9xB -----END PGP SIGNATURE----- --wxpibp5tboksjfbf--