From: "pelzflorian (Florian Pelz)" <pelzflorian@pelzflorian.de>
To: Ricardo Wurmus <rekado@elephly.net>
Cc: guix-devel@gnu.org, davet@gnu.org
Subject: Re: Web site i18n with Haunt
Date: Sun, 11 Feb 2018 17:04:14 +0100 [thread overview]
Message-ID: <20180211160413.kx75zymga66uymnf@floriannotebook> (raw)
In-Reply-To: <87tvunio07.fsf@elephly.net>
[-- Attachment #1: Type: text/plain, Size: 2177 bytes --]
On Sun, Feb 11, 2018 at 03:45:12PM +0100, Ricardo Wurmus wrote:
>
> pelzflorian (Florian Pelz) <pelzflorian@pelzflorian.de> writes:
>
> > I did not use SXPath. This one still looks ugly:
> >
> > (div (@ (id "powered-by"))
> > ,@(__ "Powered by <link \
> > url=\"https://www.gnu.org/software/guile/\">GNU Guile</link> and \
> > <link url=\"https://haunt.dthompson.us/\">Haunt</link>."
> > `(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 "…")) attribute?
>
> Since the URL isn’t supposed to be translated I wouldn’t present it as
> part of the translatable text, i.e. the string would be:
>
> Powered by <guile>GNU Guile</guile> and <haunt>Haunt</haunt>.
> […]
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’t be less verbose:
>
> (foo s
> `(link . ,(lambda (_ attr contents)
> (a-href (car ((sxpath '(url *text*)) attr)) ,contents))))
>
> (Correctly but annoyingly, “sxpath” always returns a list, so we still
> need to unpack the URL from the result with “car”.)
>
> sxpath takes a path as a list of symbols and returns a selector function
> that takes a nodeset. So the selector function applied to “attr” gets
> us a list of all “*text*” nodes inside of a “url” node in the argument
> “attr”.
>
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’ll
stick with _ albeit a somewhat unfortunate choice.
Regardsm
Florian
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
prev parent reply other threads:[~2018-02-11 16:04 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20171223125116.33r6kjnu2zze7f2o@floriannotebook>
2018-02-08 17:12 ` Haunt patches pelzflorian (Florian Pelz)
2018-02-09 13:18 ` Ludovic Courtès
2018-02-09 13:39 ` pelzflorian (Florian Pelz)
2018-02-09 17:02 ` Web site i18n with Haunt Ludovic Courtès
2018-02-09 17:47 ` pelzflorian (Florian Pelz)
2018-02-09 23:14 ` Ricardo Wurmus
2018-02-11 13:52 ` pelzflorian (Florian Pelz)
2018-02-11 14:45 ` Ricardo Wurmus
2018-02-11 16:04 ` pelzflorian (Florian Pelz) [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180211160413.kx75zymga66uymnf@floriannotebook \
--to=pelzflorian@pelzflorian.de \
--cc=davet@gnu.org \
--cc=guix-devel@gnu.org \
--cc=rekado@elephly.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).