[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: nginx: berlin: Normalize Accept-Language language
From: |
Florian Pelz |
Subject: |
branch master updated: nginx: berlin: Normalize Accept-Language language code zh to zh-CN. |
Date: |
Tue, 09 Mar 2021 06:04:47 -0500 |
This is an automated email from the git hooks/post-receive script.
pelzflorian pushed a commit to branch master
in repository maintenance.
The following commit(s) were added to refs/heads/master by this push:
new 82b0756 nginx: berlin: Normalize Accept-Language language code zh to
zh-CN.
82b0756 is described below
commit 82b075685b6089c7f98acb0993c003936d833776
Author: Florian Pelz <pelzflorian@pelzflorian.de>
AuthorDate: Thu Mar 4 20:29:27 2021 +0100
nginx: berlin: Normalize Accept-Language language code zh to zh-CN.
Now web browsers requesting any kind of Chinese get the website in
mainland Chinese.
zh, zh-Hans, zh-Hans-CN all are synonymous with zh-CN now.
Fixes <https://bugs.gnu.org/46807>.
* hydra/nginx/berlin.scm (accept-languages): New procedure.
(%extra-content): Normalize $lang variable with it.
---
hydra/nginx/berlin.scm | 27 ++++++++++++++++++++++++++-
1 file changed, 26 insertions(+), 1 deletion(-)
diff --git a/hydra/nginx/berlin.scm b/hydra/nginx/berlin.scm
index 85aaf38..4b9d297 100644
--- a/hydra/nginx/berlin.scm
+++ b/hydra/nginx/berlin.scm
@@ -995,12 +995,37 @@ PUBLISH-URL."
(uri "~ /(.*)")
(body (list "return 301 $scheme://guixwl.org/$1;"))))))))
+(define (accept-languages language-lists)
+ "Returns nginx configuration code to set up the $lang variable
+according to the Accept-Language header in the HTTP request. The
+requesting user agent will be served the files at /$lang/some/url.
+Each list in LANGUAGE-LISTS starts with the $lang and is followed by
+synonymous IETF language tags that should be mapped to the same $lang."
+ (define (language-mappings language-list)
+ (define (language-mapping language)
+ (string-join (list " " language (car language-list) ";")))
+ (string-join (map language-mapping language-list) "\n"))
+
+ (let ((directives
+ `(,(string-join
+ `("set_from_accept_language $lang_unmapped"
+ ,@(map string-join language-lists)
+ ";"))
+ "map $lang_unmapped $lang {"
+ ,@(map language-mappings language-lists)
+ "}")))
+ (string-join directives "\n")))
+
(define %extra-content
(list
"default_type application/octet-stream;"
"sendfile on;"
- "set_from_accept_language $lang en de es fr zh-CN;"
+ (accept-languages '(("en")
+ ("de")
+ ("es")
+ ("fr")
+ ("zh-CN" "zh" "zh-Hans" "zh-Hans-CN")))
;; Maximum chunk size to send. Partly this is a workaround for
;; <http://bugs.gnu.org/19939>, but also the nginx docs mention that
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: nginx: berlin: Normalize Accept-Language language code zh to zh-CN.,
Florian Pelz <=