Subject: bug#26302: [website] translations

From: "pelzflorian (Florian Pelz)" <[email-masked]>
Date: Fri, 8 Nov 2019 10:02:16 +0100

After Ludo’s reviews I’ve pushed and rebased everything again.  What
is missing is making nginx redirect accesses only to html files to
their localized version if one exists.  This would mean the
non-localized URLs remain valid and their use could be continued.

I would prefer if someone familiar with nginx could help here.

I have not researched enough to know how to redirect index files in
nginx, i.e. https://guix.gnu.org/contribute/ should serve
de/contribute/index.html.

The nginx accept language module can determine if it should redirect
to de or en like this:

diff --git a/hydra/nginx/berlin.scm b/hydra/nginx/berlin.scm
index 2947759..8b83d1e 100644
--- a/hydra/nginx/berlin.scm
+++ b/hydra/nginx/berlin.scm
@@ -468,6 +468,13 @@ PUBLISH-URL."
     (uri "/guix")
     (body (list "root /var/www;")))
 
+   (nginx-location-configuration
+    (uri "~ (.html|.htm)$")
+    (body (list
+           ;; put en first so it is the default:
+           "set_from_accept_language $lang en de;"
+           "try_files /$lang/$uri $uri =404;")))
+
    (nginx-location-configuration                  ;certbot
     (uri "/.well-known")
     (body (list "root /var/www;")))))
@@ -767,5 +774,11 @@ PUBLISH-URL."
 (define %nginx-configuration
   (nginx-configuration
    (server-blocks %berlin-servers)
+   (load-modules
+    (list
+     ;; We need this module for redirecting users to the localized
+     ;; website of their choice.
+     (file-append nginx-mod-accept-language "\
+/etc/nginx/modules/ngx_http_accept_language_module.so")))
    (extra-content
     (string-join %extra-content "\n"))))

Another thing is that perhaps the CSS margin of the .menu-item:link
elements in the navbar should be reduced.  What do you think:

https://guix.gnu.org/.i18n/de/
https://guix.gnu.org/.i18n/en/

Regards,
Florian