* Translating to Chinese, Spanish and Japanese (and more) @ 2018-02-05 9:07 Pjotr Prins 2018-02-05 9:28 ` julien lepiller 0 siblings, 1 reply; 13+ messages in thread From: Pjotr Prins @ 2018-02-05 9:07 UTC (permalink / raw) Cc: guix-devel We would like have the website translated to Chinese and some other languages that represent a large group of non-native English speakers, such as Spanish, Bengali and Japanese. For this we need to add support for i8n to haunt, which is a technical issue, but we also would like to invite native speakers to come forward and perhaps introduce some helpers who are interested in spreading free software in places that need it! It is not meant to be a lot of work, one day per language would probably do. But it needs to be someone who understands free software to get the lingo right. How do you translate 'rolling software deployment'. You don't want it to be 'fuming dragon on carpet', though that may actually be the better representation ;) We can start simply translating the front page and perhaps one or two blogs. I think that once we bootstrap there will be more people pitching in. But you need to get the attention first. Just a small sacrifice of your time with tremendous potential impact! ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Translating to Chinese, Spanish and Japanese (and more) 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 10:19 ` Ludovic Courtès 0 siblings, 2 replies; 13+ messages in thread From: julien lepiller @ 2018-02-05 9:28 UTC (permalink / raw) To: guix-devel Le 2018-02-05 10:07, Pjotr Prins a écrit : > We would like have the website translated to Chinese and some other > languages that represent a large group of non-native English speakers, > such as Spanish, Bengali and Japanese. For this we need to add support > for i8n to haunt, which is a technical issue, but we also would like > to invite native speakers to come forward and perhaps introduce some > helpers who are interested in spreading free software in places that > need it! > > It is not meant to be a lot of work, one day per language would > probably > do. But it needs to be someone who understands free software to get > the lingo right. How do you translate 'rolling software deployment'. > You don't want it to be 'fuming dragon on carpet', though that may > actually be the better representation ;) > > We can start simply translating the front page and perhaps one or two > blogs. I think that once we bootstrap there will be more people > pitching in. But you need to get the attention first. > > Just a small sacrifice of your time with tremendous potential impact! Hi, as I said during FOSDEM, I'm willing to translate the website, blog posts, and manual into French. My only concern is that the translations may fall out of sync without anyone noticing. With gettext, it's easy to know when strings are not translated, but what about the solution that would be used by haunt? ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Translating to Chinese, Spanish and Japanese (and more) 2018-02-05 9:28 ` julien lepiller @ 2018-02-05 9:41 ` pelzflorian (Florian Pelz) 2018-02-05 12:26 ` Ricardo Wurmus 2018-02-05 14:44 ` pelzflorian (Florian Pelz) 2018-02-05 10:19 ` Ludovic Courtès 1 sibling, 2 replies; 13+ messages in thread From: pelzflorian (Florian Pelz) @ 2018-02-05 9:41 UTC (permalink / raw) To: julien lepiller; +Cc: guix-devel [-- Attachment #1: Type: text/plain, Size: 2241 bytes --] On Mon, Feb 05, 2018 at 10:28:20AM +0100, julien lepiller wrote: > Le 2018-02-05 10:07, Pjotr Prins a écrit : > > We would like have the website translated to Chinese and some other > > languages that represent a large group of non-native English speakers, > > such as Spanish, Bengali and Japanese. For this we need to add support > > for i8n to haunt, which is a technical issue, but we also would like > > to invite native speakers to come forward and perhaps introduce some > > helpers who are interested in spreading free software in places that > > need it! > > > > It is not meant to be a lot of work, one day per language would probably > > do. But it needs to be someone who understands free software to get > > the lingo right. How do you translate 'rolling software deployment'. > > You don't want it to be 'fuming dragon on carpet', though that may > > actually be the better representation ;) > > > > We can start simply translating the front page and perhaps one or two > > blogs. I think that once we bootstrap there will be more people > > pitching in. But you need to get the attention first. > > > > Just a small sacrifice of your time with tremendous potential impact! > > Hi, > > as I said during FOSDEM, I'm willing to translate the website, blog > posts, and manual into French. My only concern is that the translations > may fall out of sync without anyone noticing. With gettext, it's easy > to know when strings are not translated, but what about the solution > that would be used by haunt? > How do you plan to do the translation with Haunt? 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… [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Translating to Chinese, Spanish and Japanese (and more) 2018-02-05 9:41 ` pelzflorian (Florian Pelz) @ 2018-02-05 12:26 ` Ricardo Wurmus 2018-02-05 14:47 ` pelzflorian (Florian Pelz) 2018-02-05 14:44 ` pelzflorian (Florian Pelz) 1 sibling, 1 reply; 13+ messages in thread From: Ricardo Wurmus @ 2018-02-05 12:26 UTC (permalink / raw) To: pelzflorian (Florian Pelz); +Cc: guix-devel 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 ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Translating to Chinese, Spanish and Japanese (and more) 2018-02-05 12:26 ` Ricardo Wurmus @ 2018-02-05 14:47 ` pelzflorian (Florian Pelz) 2018-02-05 17:21 ` Ricardo Wurmus 0 siblings, 1 reply; 13+ messages in thread From: pelzflorian (Florian Pelz) @ 2018-02-05 14:47 UTC (permalink / raw) To: Ricardo Wurmus; +Cc: guix-devel [-- Attachment #1: Type: text/plain, Size: 722 bytes --] On Mon, Feb 05, 2018 at 01:26:04PM +0100, Ricardo Wurmus wrote: > 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: > Ah, that is what you mean by XML. I used "link|Installation instructions" for that, but yes, maybe XML is easier to understand / more familiar for translators. I believe this Gettext support should be separate from Haunt so it can be reused e.g. for Web servers written in Guile. [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Translating to Chinese, Spanish and Japanese (and more) 2018-02-05 14:47 ` pelzflorian (Florian Pelz) @ 2018-02-05 17:21 ` Ricardo Wurmus 0 siblings, 0 replies; 13+ messages in thread From: Ricardo Wurmus @ 2018-02-05 17:21 UTC (permalink / raw) To: pelzflorian (Florian Pelz); +Cc: guix-devel pelzflorian (Florian Pelz) <pelzflorian@pelzflorian.de> writes: > On Mon, Feb 05, 2018 at 01:26:04PM +0100, Ricardo Wurmus wrote: >> 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: >> > > Ah, that is what you mean by XML. I used "link|Installation > instructions" for that, but yes, maybe XML is easier to understand / > more familiar for translators. What’s good about using XML is that we already have parser and tooling support for it. It can even be nested (though you shouldn’t go overboard with it), which may sometimes be necessary, and we can easily and programmatically access individual parts of the XML tree with sxpath and the like. > I believe this Gettext support should be separate from Haunt so it can > be reused e.g. for Web servers written in Guile. Yes, I agree. After playing with it for a while on the train it looks like it could be implemented without modifying Haunt at all. -- Ricardo GPG: BCA6 89B6 3655 3801 C3C6 2150 197A 5888 235F ACAC https://elephly.net ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Translating to Chinese, Spanish and Japanese (and more) 2018-02-05 9:41 ` pelzflorian (Florian Pelz) 2018-02-05 12:26 ` Ricardo Wurmus @ 2018-02-05 14:44 ` pelzflorian (Florian Pelz) 2018-02-06 10:17 ` pelzflorian (Florian Pelz) 1 sibling, 1 reply; 13+ messages in thread From: pelzflorian (Florian Pelz) @ 2018-02-05 14:44 UTC (permalink / raw) To: julien lepiller; +Cc: guix-devel [-- Attachment #1.1: Type: text/plain, Size: 943 bytes --] 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. [-- Attachment #1.2: 0001-page-Allow-for-creating-multiple-files-as-variants-f.patch --] [-- Type: text/plain, Size: 3121 bytes --] From c8d0fdbfdfaba2e9cab3aa7d3ab7920e317d3735 Mon Sep 17 00:00:00 2001 From: Florian Pelz <pelzflorian@pelzflorian.de> Date: Mon, 5 Feb 2018 13:08:14 +0100 Subject: [PATCH 1/2] page: Allow for creating multiple files as variants for each page. MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------2.16.1" This is a multi-part message in MIME format. --------------2.16.1 Content-Type: text/plain; charset=UTF-8; format=fixed Content-Transfer-Encoding: 8bit * haunt/page.scm: Adapt write-page to optionally build multiple variants and add helper function to transform file names. --- haunt/page.scm | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) --------------2.16.1 Content-Type: text/x-patch; name="0001-page-Allow-for-creating-multiple-files-as-variants-f.patch" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="0001-page-Allow-for-creating-multiple-files-as-variants-f.patch" diff --git a/haunt/page.scm b/haunt/page.scm index 85b2ae6..796ad24 100644 --- a/haunt/page.scm +++ b/haunt/page.scm @@ -32,6 +32,7 @@ page-file-name page-contents page-writer + variant->file-name write-page)) (define-record-type <page> @@ -41,10 +42,43 @@ (contents page-contents) (writer page-writer)) -(define (write-page page output-directory) - "Write PAGE to OUTPUT-DIRECTORY." +(define (variant->file-name variant base-file-name) + (let ((variant-as-text + (with-output-to-string + (lambda () + (display variant)))) + (period-index + (string-rindex base-file-name #\.))) + (if period-index + (string-append + (string-take base-file-name + period-index) + "." + variant-as-text + "." + (string-drop base-file-name + (1+ period-index))) + (string-append + base-file-name + "." + variant-as-text)))) + +(define* (write-page page output-directory + #:optional + variants + (variant-file-name-transformer + variant->file-name)) + "Write PAGE to OUTPUT-DIRECTORY. If VARIANTS are given, the page +contents may be a procedure that given a page variant returns SHTML. +Otherwise the page contents must be SHTML." (match page (($ <page> file-name contents writer) (let ((output (string-append output-directory "/" file-name))) (mkdir-p (dirname output)) - (call-with-output-file output (cut writer contents <>)))))) + (if (and variants (not (null? variants)) (procedure? contents)) + (for-each + (lambda (variant) + (call-with-output-file output + (cut writer (contents variant) <>))) + variants) + (call-with-output-file output (cut writer contents <>))))))) --------------2.16.1-- [-- Attachment #1.3: 0002-site-Allow-specifying-variants-in-which-to-create-ea.patch --] [-- Type: text/plain, Size: 3801 bytes --] From 8ac77740b51e905112129af0d12d2f70fd5b676e Mon Sep 17 00:00:00 2001 From: Florian Pelz <pelzflorian@pelzflorian.de> Date: Mon, 5 Feb 2018 13:13:14 +0100 Subject: [PATCH 2/2] site: Allow specifying variants in which to create each page. MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------2.16.1" This is a multi-part message in MIME format. --------------2.16.1 Content-Type: text/plain; charset=UTF-8; format=fixed Content-Transfer-Encoding: 8bit * haunt/site.scm: Add variants for which to create pages. --- haunt/site.scm | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) --------------2.16.1 Content-Type: text/x-patch; name="0002-site-Allow-specifying-variants-in-which-to-create-ea.patch" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="0002-site-Allow-specifying-variants-in-which-to-create-ea.patch" diff --git a/haunt/site.scm b/haunt/site.scm index 48573e2..6ce88a5 100644 --- a/haunt/site.scm +++ b/haunt/site.scm @@ -44,6 +44,7 @@ site-make-slug site-readers site-builders + site-variants site-post-slug build-site @@ -52,7 +53,7 @@ (define-record-type <site> (make-site title domain posts-directory file-filter build-directory - default-metadata make-slug readers builders) + default-metadata make-slug readers builders variants) site? (title site-title) (domain site-domain) @@ -62,7 +63,9 @@ (default-metadata site-default-metadata) (make-slug site-make-slug) (readers site-readers) - (builders site-builders)) + (builders site-builders) + (variants site-variants) + (variant-file-name-transformer site-variant-file-name-transformer)) (define* (site #:key (title "This Place is Haunted") @@ -73,7 +76,9 @@ (default-metadata '()) (make-slug post-slug) (readers '()) - (builders '())) + (builders '()) + (variants '()) + (variant-file-name-transformer variant->file-name)) "Create a new site object. All arguments are optional: TITLE: The name of the site @@ -86,9 +91,13 @@ DEFAULT-METADATA: An alist of arbitrary default metadata for posts whose keys are symbols MAKE-SLUG: A procedure generating a file name slug from a post READERS: A list of reader objects for processing posts -BUILDERS: A list of procedures for building pages from posts" +BUILDERS: A list of procedures for building pages from posts +VARIANTS: Variants for which to build the site’s pages +VARIANT-FILE-NAME-TRANSFORMER: Procedure to convert variant and file + name to a new file name" (make-site title domain posts-directory file-filter build-directory - default-metadata make-slug readers builders)) + default-metadata make-slug readers builders variants + variant-file-name-transformer)) (define (site-post-slug site post) "Return a slug string for POST using the slug generator for SITE." @@ -109,7 +118,9 @@ BUILDERS: A list of procedures for building pages from posts" (for-each (match-lambda ((? page? page) (format #t "writing page '~a'~%" (page-file-name page)) - (write-page page build-dir)) + (write-page page build-dir + (site-variants site) + (site-variant-file-name-transformer site))) ((? asset? asset) (format #t "copying asset '~a' → '~a'~%" (asset-source asset) --------------2.16.1-- [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: Translating to Chinese, Spanish and Japanese (and more) 2018-02-05 14:44 ` pelzflorian (Florian Pelz) @ 2018-02-06 10:17 ` pelzflorian (Florian Pelz) 2018-02-06 10:19 ` pelzflorian (Florian Pelz) 0 siblings, 1 reply; 13+ messages in thread From: pelzflorian (Florian Pelz) @ 2018-02-06 10:17 UTC (permalink / raw) To: julien lepiller; +Cc: guix-devel [-- Attachment #1: Type: text/plain, Size: 2872 bytes --] 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 #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Translating to Chinese, Spanish and Japanese (and more) 2018-02-06 10:17 ` pelzflorian (Florian Pelz) @ 2018-02-06 10:19 ` pelzflorian (Florian Pelz) 2018-03-29 10:22 ` julien lepiller 0 siblings, 1 reply; 13+ messages in thread From: pelzflorian (Florian Pelz) @ 2018-02-06 10:19 UTC (permalink / raw) To: julien lepiller; +Cc: guix-devel [-- Attachment #1.1: Type: text/plain, Size: 19 bytes --] Forgot attachment. [-- Attachment #1.2: 0001-page-Allow-for-creating-multiple-files-as-variants-f.patch --] [-- Type: text/plain, Size: 3505 bytes --] From 4a30c23a339278947db0cebbf26c80ce1585e561 Mon Sep 17 00:00:00 2001 From: Florian Pelz <pelzflorian@pelzflorian.de> Date: Mon, 5 Feb 2018 13:08:14 +0100 Subject: [PATCH 1/2] page: Allow for creating multiple files as variants for each page. MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------2.16.1" This is a multi-part message in MIME format. --------------2.16.1 Content-Type: text/plain; charset=UTF-8; format=fixed Content-Transfer-Encoding: 8bit * haunt/page.scm: Adapt write-page to optionally build multiple variants and add helper function to transform file names. --- haunt/page.scm | 50 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 45 insertions(+), 5 deletions(-) --------------2.16.1 Content-Type: text/x-patch; name="0001-page-Allow-for-creating-multiple-files-as-variants-f.patch" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="0001-page-Allow-for-creating-multiple-files-as-variants-f.patch" diff --git a/haunt/page.scm b/haunt/page.scm index 85b2ae6..1dfb123 100644 --- a/haunt/page.scm +++ b/haunt/page.scm @@ -32,6 +32,7 @@ page-file-name page-contents page-writer + variant->file-name write-page)) (define-record-type <page> @@ -41,10 +42,49 @@ (contents page-contents) (writer page-writer)) -(define (write-page page output-directory) - "Write PAGE to OUTPUT-DIRECTORY." +(define (variant->file-name variant base-file-name) + (let ((variant-as-text + (with-output-to-string + (lambda () + (display variant)))) + (period-index + (string-rindex base-file-name #\.))) + (if period-index + (string-append + (string-take base-file-name + period-index) + "." + variant-as-text + "." + (string-drop base-file-name + (1+ period-index))) + (string-append + base-file-name + "." + variant-as-text)))) + +(define* (write-page page output-directory + #:optional + variants + (variant-namer variant->file-name)) + "Write PAGE to OUTPUT-DIRECTORY. If VARIANTS are given, the page +contents may be a procedure that given a page variant returns what +data to write. Otherwise the page contents must be the data to +write." + (define (write-content-variant content-variant file-name) + (let ((output (string-append output-directory "/" file-name))) + (mkdir-p (dirname output)) + (call-with-output-file output + (cut writer content-variant <>)))) (match page (($ <page> file-name contents writer) - (let ((output (string-append output-directory "/" file-name))) - (mkdir-p (dirname output)) - (call-with-output-file output (cut writer contents <>)))))) + (if (and variants (not (null? variants)) (procedure? contents)) + (for-each + (lambda (variant) + (let ((name (variant-namer variant file-name)) + (content-variant (contents variant))) + (when content-variant + (format #t " variant '~a'~%" name) + (write-contents content-variant name)))) + variants) + (write-contents contents file-name))))) --------------2.16.1-- [-- Attachment #1.3: 0002-site-Allow-specifying-variants-in-which-to-create-ea.patch --] [-- Type: text/plain, Size: 3695 bytes --] From 1391e8c3990ed25f9a5a09ce67ef055e975bc317 Mon Sep 17 00:00:00 2001 From: Florian Pelz <pelzflorian@pelzflorian.de> Date: Mon, 5 Feb 2018 13:13:14 +0100 Subject: [PATCH 2/2] site: Allow specifying variants in which to create each page. MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------2.16.1" This is a multi-part message in MIME format. --------------2.16.1 Content-Type: text/plain; charset=UTF-8; format=fixed Content-Transfer-Encoding: 8bit * haunt/site.scm: Add variants for which to create pages. --- haunt/site.scm | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) --------------2.16.1 Content-Type: text/x-patch; name="0002-site-Allow-specifying-variants-in-which-to-create-ea.patch" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="0002-site-Allow-specifying-variants-in-which-to-create-ea.patch" diff --git a/haunt/site.scm b/haunt/site.scm index 48573e2..a321bbf 100644 --- a/haunt/site.scm +++ b/haunt/site.scm @@ -44,6 +44,7 @@ site-make-slug site-readers site-builders + site-variants site-post-slug build-site @@ -52,7 +53,8 @@ (define-record-type <site> (make-site title domain posts-directory file-filter build-directory - default-metadata make-slug readers builders) + default-metadata make-slug readers builders variants + variant-namer) site? (title site-title) (domain site-domain) @@ -62,7 +64,9 @@ (default-metadata site-default-metadata) (make-slug site-make-slug) (readers site-readers) - (builders site-builders)) + (builders site-builders) + (variants site-variants) + (variant-namer site-variant-namer)) (define* (site #:key (title "This Place is Haunted") @@ -73,7 +77,9 @@ (default-metadata '()) (make-slug post-slug) (readers '()) - (builders '())) + (builders '()) + (variants '()) + (variant-namer variant->file-name)) "Create a new site object. All arguments are optional: TITLE: The name of the site @@ -86,9 +92,12 @@ DEFAULT-METADATA: An alist of arbitrary default metadata for posts whose keys are symbols MAKE-SLUG: A procedure generating a file name slug from a post READERS: A list of reader objects for processing posts -BUILDERS: A list of procedures for building pages from posts" +BUILDERS: A list of procedures for building pages from posts +VARIANTS: Variants for which to build the site’s pages +VARIANT-NAMER: Procedure to turn variant and file name into a new name" (make-site title domain posts-directory file-filter build-directory - default-metadata make-slug readers builders)) + default-metadata make-slug readers builders variants + variant-namer)) (define (site-post-slug site post) "Return a slug string for POST using the slug generator for SITE." @@ -109,7 +118,9 @@ BUILDERS: A list of procedures for building pages from posts" (for-each (match-lambda ((? page? page) (format #t "writing page '~a'~%" (page-file-name page)) - (write-page page build-dir)) + (write-page page build-dir + (site-variants site) + (site-variant-namer site))) ((? asset? asset) (format #t "copying asset '~a' → '~a'~%" (asset-source asset) --------------2.16.1-- [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: Translating to Chinese, Spanish and Japanese (and more) 2018-02-06 10:19 ` pelzflorian (Florian Pelz) @ 2018-03-29 10:22 ` julien lepiller 2018-04-21 15:41 ` pelzflorian (Florian Pelz) 0 siblings, 1 reply; 13+ messages in thread From: julien lepiller @ 2018-03-29 10:22 UTC (permalink / raw) To: guix-devel Le 2018-02-06 11:19, pelzflorian (Florian Pelz) a écrit : > Forgot attachment. Hi, what's the status of that? In the meantime, I've found ITS (Internationalization Tag Set) and itstool: http://itstool.org/ What do you think? ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Translating to Chinese, Spanish and Japanese (and more) 2018-03-29 10:22 ` julien lepiller @ 2018-04-21 15:41 ` pelzflorian (Florian Pelz) 0 siblings, 0 replies; 13+ messages in thread From: pelzflorian (Florian Pelz) @ 2018-04-21 15:41 UTC (permalink / raw) To: julien lepiller; +Cc: guix-devel [-- Attachment #1: Type: text/plain, Size: 1378 bytes --] Hello, I am very sorry for the late reply. I got behind on my e-mail. On Thu, Mar 29, 2018 at 12:22:43PM +0200, julien lepiller wrote: > Le 2018-02-06 11:19, pelzflorian (Florian Pelz) a écrit : > > Forgot attachment. > > Hi, what's the status of that? > The current status has not changed since this discussion. http://lists.gnu.org/archive/html/guix-devel/2018-02/msg00172.html It has links to patches that I plan to work on in the coming week. I still need to document the Haunt changes and propose them to David Thompson again. > In the meantime, I've found ITS (Internationalization Tag Set) and itstool: > http://itstool.org/ > > What do you think? > This could be useful for translating blog posts that consist of just data, but for the main Haunt source code I want more control and less automation. When translating blog posts, I do not intend to use PO files, instead I just make a new file with the translated blog post for the other language’s blog. But maybe Guix would prefer PO for its blog posts. See my source code here: https://pelzflorian.de/git/pelzfloriande-website/tree/ See my po file here: https://pelzflorian.de/git/pelzfloriande-website/tree/po/de.po (Search for the “<” character to find examples of how it uses XML, using what Ricardo Wurmus proposed.) Regards, Florian [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Translating to Chinese, Spanish and Japanese (and more) 2018-02-05 9:28 ` julien lepiller 2018-02-05 9:41 ` pelzflorian (Florian Pelz) @ 2018-02-05 10:19 ` Ludovic Courtès 2018-02-05 10:49 ` pelzflorian (Florian Pelz) 1 sibling, 1 reply; 13+ messages in thread From: Ludovic Courtès @ 2018-02-05 10:19 UTC (permalink / raw) To: julien lepiller; +Cc: guix-devel Heya! For those who where not at FOSDEM: this is a topic we discussed, and the main stumbling block currently is that it’s not clear how to add i18n support in Haunt and/or the web site itself. julien lepiller <julien@lepiller.eu> skribis: > as I said during FOSDEM, I'm willing to translate the website, blog > posts, and manual into French. My only concern is that the translations > may fall out of sync without anyone noticing. With gettext, it's easy > to know when strings are not translated, but what about the solution > that would be used by haunt? The latest discussions I’m aware of on this topic are at: https://lists.gnu.org/archive/html/guile-user/2017-12/msg00024.html Florian proposed introducing a “stringly-typed” markup language to allow the translation of strings that contain markup (which sxml would prevent): https://lists.gnu.org/archive/html/guile-user/2017-12/msg00040.html At FOSDEM I thought we could maybe use XML-in-strings directly and have a macro that does ‘xml->sxml’ at expansion time, pretty much like what Florian wrote above. Anyway there are ideas floating around, so I’m sure you and Florian and others will find out! :-) Ludo’. ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Translating to Chinese, Spanish and Japanese (and more) 2018-02-05 10:19 ` Ludovic Courtès @ 2018-02-05 10:49 ` pelzflorian (Florian Pelz) 0 siblings, 0 replies; 13+ messages in thread From: pelzflorian (Florian Pelz) @ 2018-02-05 10:49 UTC (permalink / raw) To: Ludovic Courtès; +Cc: guix-devel [-- Attachment #1: Type: text/plain, Size: 2116 bytes --] On Mon, Feb 05, 2018 at 11:19:59AM +0100, Ludovic Courtès wrote: > Heya! > > For those who where not at FOSDEM: this is a topic we discussed, and the > main stumbling block currently is that it’s not clear how to add i18n > support in Haunt and/or the web site itself. > > julien lepiller <julien@lepiller.eu> skribis: > > > as I said during FOSDEM, I'm willing to translate the website, blog > > posts, and manual into French. My only concern is that the translations > > may fall out of sync without anyone noticing. With gettext, it's easy > > to know when strings are not translated, but what about the solution > > that would be used by haunt? > > The latest discussions I’m aware of on this topic are at: > > https://lists.gnu.org/archive/html/guile-user/2017-12/msg00024.html > > Florian proposed introducing a “stringly-typed” markup language to allow > the translation of strings that contain markup (which sxml would > prevent): > > https://lists.gnu.org/archive/html/guile-user/2017-12/msg00040.html > > At FOSDEM I thought we could maybe use XML-in-strings directly and have > a macro that does ‘xml->sxml’ at expansion time, pretty much like what > Florian wrote above. > > Anyway there are ideas floating around, so I’m sure you and Florian and > others will find out! :-) > > Ludo’. I don’t think translators should need to know XML or anything beside common sense and human languages. Either way, I’m happy with __ and _ functions I have at https://pelzflorian.de/git/pelzfloriande-website/tree/haunt.scm Of course other solutions are possible. I’m not happy with my using ffi-help for calling libgettext. Simply calling setlocale for each piece of SHTML is better because it is easier to understand. Using a custom Guile MO file reader would likely be faster but is not strictly necessary. So far I did not prioritize sending a patch for Haunt because I do not need it urgently. I would be thankful if others took a look. Otherwise I’ll try to implement what I described in this here e-mail thread. [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2018-04-21 15:42 UTC | newest] Thread overview: 13+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 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)
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).