[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Web site i18n with Haunt
From: |
pelzflorian (Florian Pelz) |
Subject: |
Re: Web site i18n with Haunt |
Date: |
Sun, 11 Feb 2018 17:04:14 +0100 |
User-agent: |
NeoMutt/20171208 |
On Sun, Feb 11, 2018 at 03:45:12PM +0100, Ricardo Wurmus wrote:
>
> pelzflorian (Florian Pelz) <address@hidden> 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
signature.asc
Description: PGP signature
- Re: Haunt patches, pelzflorian (Florian Pelz), 2018/02/08
- Re: Haunt patches, Ludovic Courtès, 2018/02/09
- Re: Haunt patches, pelzflorian (Florian Pelz), 2018/02/09
- Web site i18n with Haunt, Ludovic Courtès, 2018/02/09
- Re: Web site i18n with Haunt, pelzflorian (Florian Pelz), 2018/02/09
- Re: Web site i18n with Haunt, Ricardo Wurmus, 2018/02/09
- Re: Web site i18n with Haunt, pelzflorian (Florian Pelz), 2018/02/11
- Re: Web site i18n with Haunt, Ricardo Wurmus, 2018/02/11
- Re: Web site i18n with Haunt,
pelzflorian (Florian Pelz) <=