all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ricardo Wurmus <rekado@elephly.net>
To: "pelzflorian (Florian Pelz)" <pelzflorian@pelzflorian.de>
Cc: guix-devel@gnu.org
Subject: Re: Translating to Chinese, Spanish and Japanese (and more)
Date: Mon, 05 Feb 2018 13:26:04 +0100	[thread overview]
Message-ID: <87po5jd3mr.fsf@elephly.net> (raw)
In-Reply-To: <20180205094129.efgxn7nucoj3kwsf@floriannotebook>


pelzflorian (Florian Pelz) <pelzflorian@pelzflorian.de> writes:

> How do you plan to do the translation with Haunt?

Looking at the current implementation of the website, we’re dealing with
abstractions like this:

--8<---------------cut here---------------start------------->8---
(define (download dnd)
  "Return an SHTML representation of the given download object.

   DND (<download>)
     A download object as defined in (apps download types)."
  `(div
    (@ (class "download-box"))
    (img (@ (src ,(download-image dnd)) (alt "")))
    (h3 ,(download-title dnd))
    ,(download-description dnd)
    (p "Download options:")
    ,@(map (lambda (variant)
	     `(a
	       (@ (class "download-btn")
		  (download "")
		  (href ,(string-append
			  (download-base-url dnd)
			  (variant-file variant))))
	       ,(variant-label variant)
	       " ")) ; Force a space for readability in non-CSS browsers.
	  (download-variants dnd))

    (p
     "Signatures: "
     ,@(map (lambda (variant)
	     `(a
	       (@ (class "signature-btn")
		  (download "")
		  (href ,(string-append
			  (download-base-url dnd)
			  (variant-file variant) ".sig")))
	       ,(variant-label variant)
	       " ")) ; Force a space for readability in non-CSS browsers.
	    (download-variants dnd)))

    (p (a (@ (href ,(download-manual dnd))) "Installation instructions")
    ".")))
--8<---------------cut here---------------end--------------->8---

We could use the usual Gettext wrapping to provide a list of strings:
"Download options:", "Signatures: ", and "Installation instructions".
But there are two problems:

1) chopped up strings like the link label “Installation instructions”
and the trailing “.” that is outside of the link label.  Some systems
implement a DSL and present the string to translators as “%aInstallation
instructions%b.” where “%a” and “%b” are assumed to be replaced by the
anchor tags.  This is bad because it is ad-hoc and intended to be used
by gluing together strings.

Simple XML might be a better candidate for a DSL.  Translators would get
a string like “<link>Installation instructions</link>.” and give us back
a translated string such as “<link>安装说明</link>。” On the haunt side
we would have a procedure that parses the XML to SXML and we could
operate on the S-expression.  So instead of this:

    (p (a (@ (href ,(download-manual dnd))) "Installation instructions")
        ".")

we would have

    (let ((tr (G_* "<link>Installation instructions</link>.")))
     (p (sx-until '(link) tr)
        (a (@ (href ,(download-manual dnd)))
           (sx '(link *text*) tr))
        (sx-after '(link) tr)))

The procedure “G_*” would get the gettext translation for the given
string and parse the XML.  Then in haunt we can operate on the SXML with
the (sxml xpath) module, and with helpers that are built around it.

“sx”, “sxuntil”, and “sxafter” don’t exist yet, but they could be
procedures to extract the appropriate built on top of sxpath.  “sx” is
essentially this:

    (define (sx path sxml)
      (let ((match ((sxpath path) sxml)))
        (if (null? match) "OOPS"
            (car match))))


2) procedure calls like “(variant-label variant)”

The translatable output in these cases is generated SXML.  Maybe it is
sufficient to treat this as code and translate it like any other
procedure with Gettext.

--
Ricardo

GPG: BCA6 89B6 3655 3801 C3C6  2150 197A 5888 235F ACAC
https://elephly.net

  reply	other threads:[~2018-02-06  0:12 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-05  9:07 Translating to Chinese, Spanish and Japanese (and more) Pjotr Prins
2018-02-05  9:28 ` julien lepiller
2018-02-05  9:41   ` pelzflorian (Florian Pelz)
2018-02-05 12:26     ` Ricardo Wurmus [this message]
2018-02-05 14:47       ` pelzflorian (Florian Pelz)
2018-02-05 17:21         ` Ricardo Wurmus
2018-02-05 14:44     ` pelzflorian (Florian Pelz)
2018-02-06 10:17       ` pelzflorian (Florian Pelz)
2018-02-06 10:19         ` pelzflorian (Florian Pelz)
2018-03-29 10:22           ` julien lepiller
2018-04-21 15:41             ` pelzflorian (Florian Pelz)
2018-02-05 10:19   ` Ludovic Courtès
2018-02-05 10:49     ` pelzflorian (Florian Pelz)

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87po5jd3mr.fsf@elephly.net \
    --to=rekado@elephly.net \
    --cc=guix-devel@gnu.org \
    --cc=pelzflorian@pelzflorian.de \
    /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 external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.