From: "pelzflorian (Florian Pelz)" <pelzflorian@pelzflorian.de>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: guix-devel@gnu.org, sirgazil <sirgazil@zoho.com>,
matias_jose_seco@autoproduzioni.net,
julien lepiller <roptat@lepiller.eu>
Subject: Re: Website translation
Date: Sun, 25 Aug 2019 20:58:31 +0200 [thread overview]
Message-ID: <20190825185831.6bcfajoe6hcep2eo@pelzflorian.localdomain> (raw)
In-Reply-To: <874l28lx7y.fsf@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 2814 bytes --]
On Thu, Aug 22, 2019 at 11:13:53PM +0200, Ludovic Courtès wrote:
> It would be great to add the right steps to website/.guix.scm (in
> guix-artwork.git).
>
Even though the attached patches allow building with .guix.scm, I
found that my previous code does not work correctly. The
deconstruction of the translation into an sexp happened at macro
expansion time before the evaluation phase when setlocale calls took
effect, so both or neither of index.en_US.html and index.de_DE.html
contained the German translation, depending on the system-wide locale
setting.
I tried to move the deconstruction to the evaluation phase by using
local-eval:
(define (sgettext x)
"After choosing an identifier for marking s-expressions for
translation, make it usable by defining a macro with it calling
sgettext. If for example the chosen identifier is G_,
use (define-syntax G_ sgettext)."
(syntax-case x ()
((_ exp)
(let ((msgstr (sexp->msgid (syntax->datum #'exp))))
#`(local-eval (pk (deconstruct (syntax->datum #'exp)
(gettext #,msgstr)))
(the-environment))))))
which almost works, except it seems (but I am unsure) the-environment
captures the wrong environment, so functions are missing. I see:
ERROR: In procedure %resolve-variable:
error: gnu-url: unbound variable
building pages in '/tmp/gnu.org/software/guix'...
;;; ((quasiquote (h2 (@ (class "a11y-offset")) "Menü des Webauftritts:")))
;;; ((quasiquote (footer "Mit " (unquote (quasiquote (span (@ (class "metta")) "♥"))) " von Menschen gemacht und durch " (unquote (quasiquote (a (@ (class "link-yellow") (href (unquote (gnu-url "software/guile/")))) "GNU Guile"))) " ermöglicht. " (unquote (quasiquote (a (@ (class "link-yellow") (href "//git.savannah.gnu.org/cgit/guix/guix-artwork.git/tree/website")) "Quellcode"))) " unter der " (unquote (quasiquote (a (@ (class "link-yellow") (href (unquote (gnu-url "licenses/agpl-3.0.html")))) "GNU AGPL"))) ".")))
I try to find a minimal example. I add the following to the pristine
guix-website (with only my first patch):
diff --git a/website/apps/base/templates/theme.scm b/website/apps/base/templates/theme.scm
index ecb27ef..b993c2a 100644
--- a/website/apps/base/templates/theme.scm
+++ b/website/apps/base/templates/theme.scm
@@ -106,6 +106,9 @@
,(navbar #:active-item active-menu-item)
,(if (null? crumbs) "" (breadcrumbs crumbs))
+ ,(pk (let ()
+ (use-modules (ice-9 local-eval))
+ (local-eval '(gnu-url) (the-environment))))
,content
(footer
It crashes with
ERROR: In procedure %resolve-variable:
error: local-eval: unbound variable
I will continue investigating.
Regards,
Florian
[-- Attachment #2: 0007-website-Make-building-with-.guix.scm-work-with-multi.patch --]
[-- Type: text/plain, Size: 999 bytes --]
From 26d1bc2c1cea8742640be0e2b307a2e4c0397095 Mon Sep 17 00:00:00 2001
From: Florian Pelz <pelzflorian@pelzflorian.de>
Date: Sat, 24 Aug 2019 21:27:50 +0200
Subject: [PATCH 7/8] website: Make building with .guix.scm work with multiple
linguas.
* website/.guix.scm: Make Haunt build directory writable so Haunt can
overwrite duplicate assets.
---
website/.guix.scm | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/website/.guix.scm b/website/.guix.scm
index 068ef0d..5eb48b6 100644
--- a/website/.guix.scm
+++ b/website/.guix.scm
@@ -48,6 +48,11 @@
(copy-recursively #$source ".")
+ ;; Make the copy writable so Haunt can overwrite duplicate assets.
+ (invoke #+(file-append (specification->package "coreutils")
+ "/bin/chmod")
+ "--recursive" "u+w" ".")
+
;; For Haunt.
(setenv "GUILE_LOAD_PATH" (string-join %load-path ":"))
(setenv "GUILE_LOAD_COMPILED_PATH"
--
2.22.0
[-- Attachment #3: 0008-website-Have-.guix.scm-create-MO-files-for-translati.patch --]
[-- Type: text/plain, Size: 2561 bytes --]
From e367d7ba09d901c9ad4b54b919de2e3a10ba5791 Mon Sep 17 00:00:00 2001
From: Florian Pelz <pelzflorian@pelzflorian.de>
Date: Sun, 25 Aug 2019 11:59:24 +0200
Subject: [PATCH 8/8] website: Have .guix.scm create MO files for translation.
website/.guix.scm: Convert PO files to MO files for each lingua.
---
website/.guix.scm | 34 +++++++++++++++++++++++++++++++++-
1 file changed, 33 insertions(+), 1 deletion(-)
diff --git a/website/.guix.scm b/website/.guix.scm
index 5eb48b6..4a70f6a 100644
--- a/website/.guix.scm
+++ b/website/.guix.scm
@@ -21,7 +21,8 @@
(use-modules (guix) (gnu)
(guix modules)
(guix git-download)
- (ice-9 match))
+ (ice-9 match)
+ (ice-9 rdelim))
(define this-directory
(dirname (current-filename)))
@@ -36,6 +37,14 @@
(((labels packages) ...)
(cons package packages))))
+(define linguas
+ (with-input-from-file "po/LINGUAS"
+ (lambda _
+ (let loop ((line (read-line)))
+ (if (eof-object? line)
+ '()
+ (cons line (loop (read-line))))))))
+
(define build
(with-extensions (append (package+propagated-inputs
(specification->package "guix"))
@@ -53,6 +62,29 @@
"/bin/chmod")
"--recursive" "u+w" ".")
+ ;; For translations, create MO files from PO files.
+ (for-each
+ (lambda (lingua)
+ (let* ((msgfmt #+(file-append (specification->package "gettext")
+ "/bin/msgfmt"))
+ (lingua-file (string-append "po/" lingua ".po"))
+ (lang (car (string-split lingua #\_)))
+ (lang-file (string-append "po/" lang ".po")))
+ (define (create-mo filename)
+ (begin
+ (invoke msgfmt filename)
+ (mkdir-p (string-append lingua "/LC_MESSAGES"))
+ (rename-file "messages.mo"
+ (string-append lingua "/LC_MESSAGES/"
+ "guix-website.mo"))))
+ (cond
+ ((file-exists? lingua-file)
+ (create-mo lingua-file))
+ ((file-exists? lang-file)
+ (create-mo lang-file))
+ (else #t))))
+ (list #$@linguas))
+
;; For Haunt.
(setenv "GUILE_LOAD_PATH" (string-join %load-path ":"))
(setenv "GUILE_LOAD_COMPILED_PATH"
--
2.22.0
next prev parent reply other threads:[~2019-08-25 18:58 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-06 12:50 Guix beyond 1.0: let’s have a roadmap! matias_jose_seco
2019-07-07 14:20 ` Ludovic Courtès
2019-07-07 16:57 ` Website translation (was: Re: Guix beyond 1.0: let’s have a roadmap!) pelzflorian (Florian Pelz)
2019-07-07 18:00 ` pelzflorian (Florian Pelz)
2019-07-07 22:28 ` Christopher Lemmer Webber
2019-07-11 15:15 ` Website translation Ludovic Courtès
2019-07-12 5:35 ` pelzflorian (Florian Pelz)
2019-07-14 14:12 ` Ludovic Courtès
2019-07-14 14:26 ` pelzflorian (Florian Pelz)
2019-07-15 12:33 ` Ludovic Courtès
2019-07-15 14:57 ` Julien Lepiller
2019-07-15 15:54 ` pelzflorian (Florian Pelz)
2019-07-17 21:16 ` Ludovic Courtès
2019-07-18 15:08 ` pelzflorian (Florian Pelz)
2019-07-18 16:59 ` Ricardo Wurmus
2019-07-18 20:28 ` pelzflorian (Florian Pelz)
2019-07-18 20:57 ` pelzflorian (Florian Pelz)
2019-07-19 12:29 ` pelzflorian (Florian Pelz)
2019-07-26 11:11 ` pelzflorian (Florian Pelz)
2019-07-26 11:23 ` pelzflorian (Florian Pelz)
2019-08-05 13:08 ` pelzflorian (Florian Pelz)
2019-08-07 22:33 ` pelzflorian (Florian Pelz)
2019-08-22 21:13 ` Ludovic Courtès
2019-08-23 6:03 ` pelzflorian (Florian Pelz)
2019-08-23 12:18 ` Ludovic Courtès
2019-08-23 13:54 ` pelzflorian (Florian Pelz)
2019-08-23 14:08 ` Jelle Licht
2019-08-23 20:47 ` pelzflorian (Florian Pelz)
2019-08-25 18:58 ` pelzflorian (Florian Pelz) [this message]
2019-08-26 3:08 ` pelzflorian (Florian Pelz)
2019-09-06 14:27 ` pelzflorian (Florian Pelz)
2019-07-18 17:06 ` sirgazil
2019-07-15 12:59 ` Ricardo Wurmus
2019-07-18 5:06 ` 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
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=20190825185831.6bcfajoe6hcep2eo@pelzflorian.localdomain \
--to=pelzflorian@pelzflorian.de \
--cc=guix-devel@gnu.org \
--cc=ludo@gnu.org \
--cc=matias_jose_seco@autoproduzioni.net \
--cc=roptat@lepiller.eu \
--cc=sirgazil@zoho.com \
/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).