guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Translating to Chinese, Spanish and Japanese (and more)


From: pelzflorian (Florian Pelz)
Subject: Re: Translating to Chinese, Spanish and Japanese (and more)
Date: Tue, 6 Feb 2018 11:17:50 +0100
User-agent: NeoMutt/20171208

On Mon, Feb 05, 2018 at 03:44:30PM +0100, pelzflorian (Florian Pelz) wrote:
> On Mon, Feb 05, 2018 at 10:41:29AM +0100, pelzflorian (Florian Pelz) wrote:
> > I thought about making page translations possible by allowing page
> > bodies to be lambdas taking a page variant as an argument, e.g. a
> > string containing an ietf language code, and returning the body
> > S-expression.
> > 
> > Then the page variants could be specified per site and each page would
> > be generated once per variant.
> > 
> > A site’s post-template and collection-template could then also
> > optionally be lambdas returning SHTML instead of SHTML.
> > 
> > It should also be possible to specify a procedure to transform a base
> > page name and a language variant to a new page name.
> > 
> > I still did not have time to send a patch though…
> 
> Basically what I mean is to generate multiple variants of each Haunt
> page, e.g. one for each locale.  See the attached patches.  I did not
> try them yet neither document nor test them.  Will do so later.

I am currently in the process of reworking my website to use page
variants.  It is not done and not public yet.  This change in Haunt
would mean:

Sites now have two more keys: VARIANTS and VARIANT-NAMER.

VARIANTS may be a list of page variants.  For me, it is a list of
languages (“linguas”), i.e. '("de" "en"), but variants could be
anything and also used for web pages that differ not in language but
something else.  If VARIANTS is not a list but the empty list '() or
#f, everything works as before without page variants.  By default it
is '().

VARIANT-NAMER is a lambda that given a variant from VARIANTS and a
page’s file name returns the “real” file name for the variant.  The
default puts the page’s variant before the extension separated by a
period, i.e. jabberwocky.html becomes jabberwocky.en.html.

Each page’s contents may be a procedure that given a variant from
VARIANTS returns the “real” contents.  The variant can be used in a
gettext macro _ (or __ for inserting code into the translation) in the
body to look up translations, but to do so is up to the Haunt user and
is not part of Haunt.  If the procedure returns #f this variant is not
generated.  If the page body is not a procedure the page is generated
once as if there were no page variants.

Blog builder layouts return page contents and thus may return a
procedure that given a variant from VARIANTS return the “real” SHTML.
It is up to the Haunt user how to interpret e.g. post titles in the
layout.  I plan to consider titles a procedure and call them with the
variant of the page to get the translated title.

I hope all of this works.  When I’ve tried it on my website, I will
send a patch to David Thompson.  What I currently have is attached.

Regards,
Florian

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]