haunt-i18n.scm
1 | ;;; Nani Project website |
2 | ;;; Copyright © 2019 Julien Lepiller <julien@lepiller.eu> |
3 | ;;; |
4 | ;;; This file is part of the Nani Project website. |
5 | ;;; |
6 | ;;; The Nani Project website is free software; you can redistribute it and/or modify it |
7 | ;;; under the terms of the GNU Affero General Public License as published by |
8 | ;;; the Free Software Foundation; either version 3 of the License, or (at |
9 | ;;; your option) any later version. |
10 | ;;; |
11 | ;;; The Nani Project website is distributed in the hope that it will be useful, but |
12 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | ;;; GNU Affero General Public License for more details. |
15 | ;;; |
16 | ;;; You should have received a copy of the GNU Affero General Public License |
17 | ;;; along with the Nani Project website. If not, see <http://www.gnu.org/licenses/>. |
18 | |
19 | (define-module (tools haunt-i18n) |
20 | #:use-module (haunt builder blog) |
21 | #:use-module (haunt html) |
22 | #:use-module (haunt page) |
23 | #:use-module (sxml simple) |
24 | #:use-module (ice-9 match) |
25 | #:use-module (tools i18n) |
26 | #:export (internationalize)) |
27 | |
28 | (define (make-my-page lang title filename body layout) |
29 | (lambda (site posts) |
30 | (define (my-body) |
31 | (site-locale lang) |
32 | (tr body)) |
33 | (make-page (if (equal? lang "") |
34 | (string-append filename ".html") |
35 | (string-append filename "." lang ".html")) |
36 | (with-layout (layout lang filename) site title (my-body)) |
37 | sxml->html))) |
38 | |
39 | (define (internationalize title filename body layout) |
40 | (map (lambda (lang) (make-my-page lang title filename body layout)) languages)) |
41 |