From mboxrd@z Thu Jan 1 00:00:00 1970 From: "pelzflorian (Florian Pelz)" Subject: Re: Web site i18n with Haunt Date: Sun, 11 Feb 2018 17:04:14 +0100 Message-ID: <20180211160413.kx75zymga66uymnf@floriannotebook> References: <20171223125116.33r6kjnu2zze7f2o@floriannotebook> <20180208171243.dnligzfvwsxvc4l3@floriannotebook> <87a7wi2tey.fsf@gnu.org> <20180209133949.dvl2dry7oija5ayl@floriannotebook> <87y3k2xfj5.fsf_-_@gnu.org> <20180209174745.nlhk3vv3si7u4vs2@floriannotebook> <877erl7o31.fsf@elephly.net> <20180211135230.eowx3yvvm3fll3i6@floriannotebook> <87tvunio07.fsf@elephly.net> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="5w56sm2ke2iov3jd" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:43776) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eku77-0004ym-BF for guix-devel@gnu.org; Sun, 11 Feb 2018 11:04:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eku76-0007by-4Y for guix-devel@gnu.org; Sun, 11 Feb 2018 11:04:25 -0500 Content-Disposition: inline In-Reply-To: <87tvunio07.fsf@elephly.net> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: Ricardo Wurmus Cc: guix-devel@gnu.org, davet@gnu.org --5w56sm2ke2iov3jd Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Feb 11, 2018 at 03:45:12PM +0100, Ricardo Wurmus wrote: >=20 > pelzflorian (Florian Pelz) writes: >=20 > > I did not use SXPath. This one still looks ugly: > > > > (div (@ (id "powered-by")) > > ,@(__ "Powered by > url=3D\"https://www.gnu.org/software/guile/\">GNU Guile and \ > > Haunt." > > `(link > > . ,(lambda (tag attr text) > > (a-href > > (cadadr attr) > > text))))) > > > > I suppose I should have used SXPath for it to get the URL out of the > > (@ (url "=E2=80=A6")) attribute? >=20 > Since the URL isn=E2=80=99t supposed to be translated I wouldn=E2=80=99t = present it as > part of the translatable text, i.e. the string would be: >=20 > Powered by GNU Guile and Haunt. > [=E2=80=A6] Well, if eventually the websites of Guile and/or Haunt were to be translated, then I would like to localize the URL. ;) > You could use sxpath to avoid cadadr, but it wouldn=E2=80=99t be less ver= bose: >=20 > (foo s > `(link . ,(lambda (_ attr contents) > (a-href (car ((sxpath '(url *text*)) attr)) ,contents)))) >=20 > (Correctly but annoyingly, =E2=80=9Csxpath=E2=80=9D always returns a list= , so we still > need to unpack the URL from the result with =E2=80=9Ccar=E2=80=9D.) >=20 > sxpath takes a path as a list of symbols and returns a selector function > that takes a nodeset. So the selector function applied to =E2=80=9Cattr= =E2=80=9D gets > us a list of all =E2=80=9C*text*=E2=80=9D nodes inside of a =E2=80=9Curl= =E2=80=9D node in the argument > =E2=80=9Cattr=E2=80=9D. >=20 I switched my website to use your sxpath code. Thank you. It is more maintainable and I do not really care about verbosity. The SXPath info page was too long for me to read thoroughly without examples. I chose not to use _ as its the same as what I use for my Gettext macro. sirgazil said here https://lists.gnu.org/archive/html/guile-devel/2017-12/msg00051.html that they prefer l10n as the gettext alias instead of _. I guess I=E2=80= =99ll stick with _ albeit a somewhat unfortunate choice. Regardsm Florian --5w56sm2ke2iov3jd Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEwRjGsqAMqXB4uw3y3T6EbElHBVsFAlqAaVcACgkQ3T6EbElH BVuitA//Xhqg0S970Q/MB2SZnZJvZ8HyPua9cSNDLKLikYnL0QIBtdPs25DWkBwU eK4dhjiAON4XUu6Jg/QkEy5PGJaWiEhl1dbpfPMTUp9LCMiz4LZn4YIq1zI6tCRt 9pidVBvQm7ro7D4um+mtiiKNMAQjJ9YwYXpY2rcdV34MhPFuey5HfErzIFfl6Bjv tpiwp+SbeLpFBCfJA125RWUPpW9mZQMX0R9OriQF2IlPCi9LCyMB0djRczl4RXUU bkTRB68TdKTL4NcrEkuBzAXdlfR6GxTZ46pVHnwzjskUPxhgOnNbPT+0Wi5t0mOA LJG6uNCode4jTiysiUxH7gaIJ9SklLXgIr7rlQG31FLP0mq+KQqCSd+GMTHtFFl0 mu/3w3wWM/nEDL9KDRYQIWKN3PDUD9SnLpBBH2+DKEZchY6xLsAIH5qc3s/kF/pI YLkt0Z34QLT9om2n+qHaCqP71eL7b9QLvfIRN5AvIprYLKOLGRYjTcIUCmS4p3FW VpGuUenFUE88HNL/tq7S50D6QoNQf518woB9fp7Mm1qbFh1D4jZvfxmKMGcm647J KOipG8WAs/6KNxn0ZqmpllWQOQcXlV6KTSvhH2s+PEJKRjhwi0A9XbNdzMPQjKX7 Sfpk6CqBizptI7rs9FqONTcg/fgm+YNeXhMLTLXr1g1yQvOZ79Q= =htWd -----END PGP SIGNATURE----- --5w56sm2ke2iov3jd--