01/09: website: Add custom xgettext to extract from nested sexps for i18n.
pelzflorian pushed a commit to branch wip-i18n in repository guix-artwork. commit 5877dcf0730a0fa2470c1bb5b6e7dd89f71bf1cd Author: Florian Pelz AuthorDate: Wed Oct 30 08:22:47 2019 + website: Add custom xgettext to extract from nested sexps for i18n. * website/po/POTFILES: New file. List apps files here. * website/po/LINGUAS: New file. List en_US lingua. * website/po/ietf-tags.scm: New file. Add association for en_US lingua. * website/scripts/sexp-xgettext.scm: New file for generating a POT file. (, , ): New record types. (combine-duplicate-po-entries, complex-keyword-spec?, parse-scheme-file, po-equal?, write-po-entry, update-ecomments-string!, update-file-name!, update-old-line-number!, update-line-number!, incr-line-number!, incr-line-number-for-each-nl!, current-ref, make-simple-po-entry, matching-keyword, nth-exp, more-than-one-exp?, token->string-symbol-or-keyw, complex-marked-list->po-entries, construct-po-entries, tag, construct-msgid-and-po-entries, scheme-file->po-entries): New procedures. (%keyword-specs, %options, %comments-line, %ecomments-string, %file-name, %old-line-number, %line-number, %files-from-port, %source-files, %output-po-entries, %output-port): New variables. * website/sexp-xgettext.scm: New file with module for looking up translations. (%complex-keywords, %simple-keywords, %plural-numbers, %linguas): New variables. (, ): New record types. (set-complex-keywords!, set-simple-keywords!, gettext-keyword?, tag, sexp->msgid, deconstruct): New procedures. (sgettext, spgettext, sngettext, snpgettext): New macro helpers. * website/apps/i18n.scm: New file. (G_, N_, C_, NC_, ietf-tags-file-contents): New syntax to use for i18n. (%current-ietf-tag, %current-lang, %current-lingua): New variables. (builder->localized-builder, builders->localized-builders, localized-root-path, first-value): New utility procedures. (, ): New imports from Haunt. * website/haunt.scm: Wrap each builder to build the locale set in LC_ALL. * website/.guix.scm: Make Haunt build directory writable so Haunt can overwrite duplicate assets. Convert PO files to MO files and build for each lingua. * website/README: Adapt build instructions for i18n. * website/i18n-howto: New file with usage instructions. --- website/.guix.scm | 80 +++- website/README| 8 +- website/apps/i18n.scm | 132 ++ website/haunt.scm | 19 +- website/i18n-howto.txt| 86 website/po/LINGUAS| 3 + website/po/POTFILES | 36 ++ website/po/ietf-tags.scm | 9 + website/scripts/sexp-xgettext.scm | 830 ++ website/sexp-xgettext.scm | 530 10 files changed, 1707 insertions(+), 26 deletions(-) diff --git a/website/.guix.scm b/website/.guix.scm index aac1c8c..fe1119c 100644 --- a/website/.guix.scm +++ b/website/.guix.scm @@ -1,5 +1,6 @@ ;;; GNU Guix web site ;;; Copyright © 2017, 2019, 2020 Ludovic Courtès +;;; Copyright © 2019 Florian Pelz ;;; ;;; This file is part of the GNU Guix web site. ;;; @@ -18,16 +19,27 @@ ;; Run 'guix build -f .guix.scm' to build the web site. +(define this-directory + (dirname (current-filename))) + +;; Make sure po/LINGUAS will be found in the current working +;; directory. +(chdir this-directory) + +;; We need %linguas from the (sexp-xgettext) module. +;; Therefore, we add its path to the load path. +(set! %load-path (cons this-directory %load-path)) + (use-modules (guix) (gnu) (guix modules) (guix git-download) (guix gexp) (guix channels) (srfi srfi-9) - (ice-9 match)) - -(define this-directory - (dirname (current-filename))) + (ice-9 match) + (ice-9 rdelim) + (ice-9 regex) + (sexp-xgettext)) (define source (local-file this-directory "guix-web-site" @@ -73,9 +85,7 @@ (setvbuf (current-output-port) 'line) (setvbuf (current-error-port) 'line) - (copy-recursively #$source ".") - ;; Set 'GUILE_LOAD_PATH' so that Haunt find the Guix modules and ;; its dependencies. To find out the load path of Guix and its ;; dependencies, fetch its value over 'guix repl'. @@ -96,24 +106,62 @@ ":" (close-pipe pipe)) + ;; Make the copy writable so Haunt can overwrite duplicate assets. + (invoke #+(file-append (specification->package "coreutils") + "/bin/chmod") + "--recursive" "u+w" ".") + + ;; For translations, create MO files from PO files. + (for-each + (lambda (lingua) + (let* ((msgfmt #+(file-append +
01/09: website: Add custom xgettext to extract from nested sexps for i18n.
pelzflorian pushed a commit to branch wip-i18n in repository guix-artwork. commit 77675f1778bbc8602e16f6b52ce66524cc892710 Author: Florian Pelz Date: Wed Oct 30 08:22:47 2019 + website: Add custom xgettext to extract from nested sexps for i18n. * website/po/POTFILES: New file. List apps files here. * website/po/LINGUAS: New file. List en_US lingua. * website/po/ietf-tags.scm: New file. Add association for en_US lingua. * website/scripts/sexp-xgettext.scm: New file for generating a POT file. (, , ): New record types. (combine-duplicate-po-entries, complex-keyword-spec?, parse-scheme-file, po-equal?, write-po-entry, update-ecomments-string!, update-file-name!, update-old-line-number!, update-line-number!, incr-line-number!, incr-line-number-for-each-nl!, current-ref, make-simple-po-entry, matching-keyword, nth-exp, more-than-one-exp?, token->string-symbol-or-keyw, complex-marked-list->po-entries, construct-po-entries, tag, construct-msgid-and-po-entries, scheme-file->po-entries): New procedures. (%keyword-specs, %options, %comments-line, %ecomments-string, %file-name, %old-line-number, %line-number, %files-from-port, %source-files, %output-po-entries, %output-port): New variables. * website/sexp-xgettext.scm: New file with module for looking up translations. (%complex-keywords, %simple-keywords, %plural-numbers, %linguas): New variables. (, ): New record types. (set-complex-keywords!, set-simple-keywords!, gettext-keyword?, tag, sexp->msgid, deconstruct): New procedures. (sgettext, spgettext, sngettext, snpgettext): New macro helpers. * website/apps/i18n.scm: New file. (G_, N_, C_, NC_, ietf-tags-file-contents): New syntax to use for i18n. (%current-ietf-tag, %current-lang, %current-lingua): New variables. (builder->localized-builder, builders->localized-builders, localized-root-path, first-value): New utility procedures. (, ): New imports from Haunt. * website/haunt.scm: Wrap each builder to build the locale set in LC_ALL. * website/.guix.scm: Make Haunt build directory writable so Haunt can overwrite duplicate assets. Convert PO files to MO files and build for each lingua. * website/README: Adapt build instructions for i18n. * website/i18n-howto: New file with usage instructions. --- website/.guix.scm | 80 +++- website/README| 8 +- website/apps/i18n.scm | 132 ++ website/haunt.scm | 19 +- website/i18n-howto.txt| 86 website/po/LINGUAS| 3 + website/po/POTFILES | 36 ++ website/po/ietf-tags.scm | 9 + website/scripts/sexp-xgettext.scm | 830 ++ website/sexp-xgettext.scm | 530 10 files changed, 1707 insertions(+), 26 deletions(-) diff --git a/website/.guix.scm b/website/.guix.scm index 8f44c90..9510779 100644 --- a/website/.guix.scm +++ b/website/.guix.scm @@ -1,5 +1,6 @@ ;;; GNU Guix web site ;;; Copyright © 2017, 2019 Ludovic Courtès +;;; Copyright © 2019 Florian Pelz ;;; ;;; This file is part of the GNU Guix web site. ;;; @@ -18,16 +19,27 @@ ;; Run 'guix build -f .guix.scm' to build the web site. +(define this-directory + (dirname (current-filename))) + +;; Make sure po/LINGUAS will be found in the current working +;; directory. +(chdir this-directory) + +;; We need %linguas from the (sexp-xgettext) module. +;; Therefore, we add its path to the load path. +(set! %load-path (cons this-directory %load-path)) + (use-modules (guix) (gnu) (guix modules) (guix git-download) (guix gexp) (guix channels) (srfi srfi-9) - (ice-9 match)) - -(define this-directory - (dirname (current-filename))) + (ice-9 match) + (ice-9 rdelim) + (ice-9 regex) + (sexp-xgettext)) (define source (local-file this-directory "guix-web-site" @@ -73,9 +85,7 @@ (setvbuf (current-output-port) 'line) (setvbuf (current-error-port) 'line) - (copy-recursively #$source ".") - ;; Set 'GUILE_LOAD_PATH' so that Haunt find the Guix modules and ;; its dependencies. To find out the load path of Guix and its ;; dependencies, fetch its value over 'guix repl'. @@ -96,24 +106,62 @@ ":" (close-pipe pipe)) + ;; Make the copy writable so Haunt can overwrite duplicate assets. + (invoke #+(file-append (specification->package "coreutils") + "/bin/chmod") + "--recursive" "u+w" ".") + + ;; For translations, create MO files from PO files. + (for-each + (lambda (lingua) + (let* ((msgfmt #+(file-append +
01/09: website: Add custom xgettext to extract from nested sexps for i18n.
pelzflorian pushed a commit to branch wip-i18n in repository guix-artwork. commit 77675f1778bbc8602e16f6b52ce66524cc892710 Author: Florian Pelz Date: Wed Oct 30 08:22:47 2019 + website: Add custom xgettext to extract from nested sexps for i18n. * website/po/POTFILES: New file. List apps files here. * website/po/LINGUAS: New file. List en_US lingua. * website/po/ietf-tags.scm: New file. Add association for en_US lingua. * website/scripts/sexp-xgettext.scm: New file for generating a POT file. (, , ): New record types. (combine-duplicate-po-entries, complex-keyword-spec?, parse-scheme-file, po-equal?, write-po-entry, update-ecomments-string!, update-file-name!, update-old-line-number!, update-line-number!, incr-line-number!, incr-line-number-for-each-nl!, current-ref, make-simple-po-entry, matching-keyword, nth-exp, more-than-one-exp?, token->string-symbol-or-keyw, complex-marked-list->po-entries, construct-po-entries, tag, construct-msgid-and-po-entries, scheme-file->po-entries): New procedures. (%keyword-specs, %options, %comments-line, %ecomments-string, %file-name, %old-line-number, %line-number, %files-from-port, %source-files, %output-po-entries, %output-port): New variables. * website/sexp-xgettext.scm: New file with module for looking up translations. (%complex-keywords, %simple-keywords, %plural-numbers, %linguas): New variables. (, ): New record types. (set-complex-keywords!, set-simple-keywords!, gettext-keyword?, tag, sexp->msgid, deconstruct): New procedures. (sgettext, spgettext, sngettext, snpgettext): New macro helpers. * website/apps/i18n.scm: New file. (G_, N_, C_, NC_, ietf-tags-file-contents): New syntax to use for i18n. (%current-ietf-tag, %current-lang, %current-lingua): New variables. (builder->localized-builder, builders->localized-builders, localized-root-path, first-value): New utility procedures. (, ): New imports from Haunt. * website/haunt.scm: Wrap each builder to build the locale set in LC_ALL. * website/.guix.scm: Make Haunt build directory writable so Haunt can overwrite duplicate assets. Convert PO files to MO files and build for each lingua. * website/README: Adapt build instructions for i18n. * website/i18n-howto: New file with usage instructions. --- website/.guix.scm | 80 +++- website/README| 8 +- website/apps/i18n.scm | 132 ++ website/haunt.scm | 19 +- website/i18n-howto.txt| 86 website/po/LINGUAS| 3 + website/po/POTFILES | 36 ++ website/po/ietf-tags.scm | 9 + website/scripts/sexp-xgettext.scm | 830 ++ website/sexp-xgettext.scm | 530 10 files changed, 1707 insertions(+), 26 deletions(-) diff --git a/website/.guix.scm b/website/.guix.scm index 8f44c90..9510779 100644 --- a/website/.guix.scm +++ b/website/.guix.scm @@ -1,5 +1,6 @@ ;;; GNU Guix web site ;;; Copyright © 2017, 2019 Ludovic Courtès +;;; Copyright © 2019 Florian Pelz ;;; ;;; This file is part of the GNU Guix web site. ;;; @@ -18,16 +19,27 @@ ;; Run 'guix build -f .guix.scm' to build the web site. +(define this-directory + (dirname (current-filename))) + +;; Make sure po/LINGUAS will be found in the current working +;; directory. +(chdir this-directory) + +;; We need %linguas from the (sexp-xgettext) module. +;; Therefore, we add its path to the load path. +(set! %load-path (cons this-directory %load-path)) + (use-modules (guix) (gnu) (guix modules) (guix git-download) (guix gexp) (guix channels) (srfi srfi-9) - (ice-9 match)) - -(define this-directory - (dirname (current-filename))) + (ice-9 match) + (ice-9 rdelim) + (ice-9 regex) + (sexp-xgettext)) (define source (local-file this-directory "guix-web-site" @@ -73,9 +85,7 @@ (setvbuf (current-output-port) 'line) (setvbuf (current-error-port) 'line) - (copy-recursively #$source ".") - ;; Set 'GUILE_LOAD_PATH' so that Haunt find the Guix modules and ;; its dependencies. To find out the load path of Guix and its ;; dependencies, fetch its value over 'guix repl'. @@ -96,24 +106,62 @@ ":" (close-pipe pipe)) + ;; Make the copy writable so Haunt can overwrite duplicate assets. + (invoke #+(file-append (specification->package "coreutils") + "/bin/chmod") + "--recursive" "u+w" ".") + + ;; For translations, create MO files from PO files. + (for-each + (lambda (lingua) + (let* ((msgfmt #+(file-append +
01/09: website: Add custom xgettext to extract from nested sexps for i18n.
pelzflorian pushed a commit to branch wip-i18n in repository guix-artwork. commit 77675f1778bbc8602e16f6b52ce66524cc892710 Author: Florian Pelz Date: Wed Oct 30 08:22:47 2019 + website: Add custom xgettext to extract from nested sexps for i18n. * website/po/POTFILES: New file. List apps files here. * website/po/LINGUAS: New file. List en_US lingua. * website/po/ietf-tags.scm: New file. Add association for en_US lingua. * website/scripts/sexp-xgettext.scm: New file for generating a POT file. (, , ): New record types. (combine-duplicate-po-entries, complex-keyword-spec?, parse-scheme-file, po-equal?, write-po-entry, update-ecomments-string!, update-file-name!, update-old-line-number!, update-line-number!, incr-line-number!, incr-line-number-for-each-nl!, current-ref, make-simple-po-entry, matching-keyword, nth-exp, more-than-one-exp?, token->string-symbol-or-keyw, complex-marked-list->po-entries, construct-po-entries, tag, construct-msgid-and-po-entries, scheme-file->po-entries): New procedures. (%keyword-specs, %options, %comments-line, %ecomments-string, %file-name, %old-line-number, %line-number, %files-from-port, %source-files, %output-po-entries, %output-port): New variables. * website/sexp-xgettext.scm: New file with module for looking up translations. (%complex-keywords, %simple-keywords, %plural-numbers, %linguas): New variables. (, ): New record types. (set-complex-keywords!, set-simple-keywords!, gettext-keyword?, tag, sexp->msgid, deconstruct): New procedures. (sgettext, spgettext, sngettext, snpgettext): New macro helpers. * website/apps/i18n.scm: New file. (G_, N_, C_, NC_, ietf-tags-file-contents): New syntax to use for i18n. (%current-ietf-tag, %current-lang, %current-lingua): New variables. (builder->localized-builder, builders->localized-builders, localized-root-path, first-value): New utility procedures. (, ): New imports from Haunt. * website/haunt.scm: Wrap each builder to build the locale set in LC_ALL. * website/.guix.scm: Make Haunt build directory writable so Haunt can overwrite duplicate assets. Convert PO files to MO files and build for each lingua. * website/README: Adapt build instructions for i18n. * website/i18n-howto: New file with usage instructions. --- website/.guix.scm | 80 +++- website/README| 8 +- website/apps/i18n.scm | 132 ++ website/haunt.scm | 19 +- website/i18n-howto.txt| 86 website/po/LINGUAS| 3 + website/po/POTFILES | 36 ++ website/po/ietf-tags.scm | 9 + website/scripts/sexp-xgettext.scm | 830 ++ website/sexp-xgettext.scm | 530 10 files changed, 1707 insertions(+), 26 deletions(-) diff --git a/website/.guix.scm b/website/.guix.scm index 8f44c90..9510779 100644 --- a/website/.guix.scm +++ b/website/.guix.scm @@ -1,5 +1,6 @@ ;;; GNU Guix web site ;;; Copyright © 2017, 2019 Ludovic Courtès +;;; Copyright © 2019 Florian Pelz ;;; ;;; This file is part of the GNU Guix web site. ;;; @@ -18,16 +19,27 @@ ;; Run 'guix build -f .guix.scm' to build the web site. +(define this-directory + (dirname (current-filename))) + +;; Make sure po/LINGUAS will be found in the current working +;; directory. +(chdir this-directory) + +;; We need %linguas from the (sexp-xgettext) module. +;; Therefore, we add its path to the load path. +(set! %load-path (cons this-directory %load-path)) + (use-modules (guix) (gnu) (guix modules) (guix git-download) (guix gexp) (guix channels) (srfi srfi-9) - (ice-9 match)) - -(define this-directory - (dirname (current-filename))) + (ice-9 match) + (ice-9 rdelim) + (ice-9 regex) + (sexp-xgettext)) (define source (local-file this-directory "guix-web-site" @@ -73,9 +85,7 @@ (setvbuf (current-output-port) 'line) (setvbuf (current-error-port) 'line) - (copy-recursively #$source ".") - ;; Set 'GUILE_LOAD_PATH' so that Haunt find the Guix modules and ;; its dependencies. To find out the load path of Guix and its ;; dependencies, fetch its value over 'guix repl'. @@ -96,24 +106,62 @@ ":" (close-pipe pipe)) + ;; Make the copy writable so Haunt can overwrite duplicate assets. + (invoke #+(file-append (specification->package "coreutils") + "/bin/chmod") + "--recursive" "u+w" ".") + + ;; For translations, create MO files from PO files. + (for-each + (lambda (lingua) + (let* ((msgfmt #+(file-append +
01/09: website: Add custom xgettext to extract from nested sexps for i18n.
pelzflorian pushed a commit to branch wip-i18n in repository guix-artwork. commit 7fbe99dac1e0eaeec06b6ab2d8dffd6a98b00f86 Author: Florian Pelz Date: Wed Oct 30 08:22:47 2019 + website: Add custom xgettext to extract from nested sexps for i18n. * website/po/POTFILES: New file. List apps files here. * website/po/LINGUAS: New file. List en_US lingua. * website/po/ietf-tags.scm: New file. Add association for en_US lingua. * website/scripts/sexp-xgettext.scm: New file for generating a POT file. (, , ): New record types. (combine-duplicate-po-entries, complex-keyword-spec?, parse-scheme-file, po-equal?, write-po-entry, update-ecomments-string!, update-file-name!, update-old-line-number!, update-line-number!, incr-line-number!, incr-line-number-for-each-nl!, current-ref, make-simple-po-entry, matching-keyword, nth-exp, more-than-one-exp?, token->string-symbol-or-keyw, complex-marked-list->po-entries, construct-po-entries, tag, construct-msgid-and-po-entries, scheme-file->po-entries): New procedures. (%keyword-specs, %options, %comments-line, %ecomments-string, %file-name, %old-line-number, %line-number, %files-from-port, %source-files, %output-po-entries, %output-port): New variables. * website/sexp-xgettext.scm: New file with module for looking up translations. (%complex-keywords, %simple-keywords, %plural-numbers, %linguas): New variables. (, ): New record types. (set-complex-keywords!, set-simple-keywords!, gettext-keyword?, tag, sexp->msgid, deconstruct): New procedures. (sgettext, spgettext, sngettext, snpgettext): New macro helpers. * website/apps/i18n.scm: New file. (G_, N_, C_, NC_, ietf-tags-file-contents): New syntax to use for i18n. (%current-ietf-tag, %current-lang, %current-lingua): New variables. (builder->localized-builder, builders->localized-builders, localized-root-path, first-value): New utility procedures. (, ): New imports from Haunt. * website/haunt.scm: Wrap each builder to build the locale set in LC_ALL. * website/.guix.scm: Make Haunt build directory writable so Haunt can overwrite duplicate assets. Convert PO files to MO files and build for each lingua. * website/README: Adapt build instructions for i18n. * website/i18n-howto: New file with usage instructions. --- website/.guix.scm | 80 +++- website/README| 8 +- website/apps/i18n.scm | 132 ++ website/haunt.scm | 19 +- website/i18n-howto.txt| 86 website/po/LINGUAS| 3 + website/po/POTFILES | 36 ++ website/po/ietf-tags.scm | 9 + website/scripts/sexp-xgettext.scm | 830 ++ website/sexp-xgettext.scm | 530 10 files changed, 1707 insertions(+), 26 deletions(-) diff --git a/website/.guix.scm b/website/.guix.scm index 8f44c90..9510779 100644 --- a/website/.guix.scm +++ b/website/.guix.scm @@ -1,5 +1,6 @@ ;;; GNU Guix web site ;;; Copyright © 2017, 2019 Ludovic Courtès +;;; Copyright © 2019 Florian Pelz ;;; ;;; This file is part of the GNU Guix web site. ;;; @@ -18,16 +19,27 @@ ;; Run 'guix build -f .guix.scm' to build the web site. +(define this-directory + (dirname (current-filename))) + +;; Make sure po/LINGUAS will be found in the current working +;; directory. +(chdir this-directory) + +;; We need %linguas from the (sexp-xgettext) module. +;; Therefore, we add its path to the load path. +(set! %load-path (cons this-directory %load-path)) + (use-modules (guix) (gnu) (guix modules) (guix git-download) (guix gexp) (guix channels) (srfi srfi-9) - (ice-9 match)) - -(define this-directory - (dirname (current-filename))) + (ice-9 match) + (ice-9 rdelim) + (ice-9 regex) + (sexp-xgettext)) (define source (local-file this-directory "guix-web-site" @@ -73,9 +85,7 @@ (setvbuf (current-output-port) 'line) (setvbuf (current-error-port) 'line) - (copy-recursively #$source ".") - ;; Set 'GUILE_LOAD_PATH' so that Haunt find the Guix modules and ;; its dependencies. To find out the load path of Guix and its ;; dependencies, fetch its value over 'guix repl'. @@ -96,24 +106,62 @@ ":" (close-pipe pipe)) + ;; Make the copy writable so Haunt can overwrite duplicate assets. + (invoke #+(file-append (specification->package "coreutils") + "/bin/chmod") + "--recursive" "u+w" ".") + + ;; For translations, create MO files from PO files. + (for-each + (lambda (lingua) + (let* ((msgfmt #+(file-append +