]> git.plutz.net Git - webpoll/commitdiff
first attempt of internationalization
authorPaul Hänsch <paul@plutz.net>
Wed, 27 Jul 2022 11:59:07 +0000 (13:59 +0200)
committerPaul Hänsch <paul@plutz.net>
Wed, 27 Jul 2022 11:59:07 +0000 (13:59 +0200)
languages.sh [new file with mode: 0644]
poll.sh

diff --git a/languages.sh b/languages.sh
new file mode 100644 (file)
index 0000000..c3649f4
--- /dev/null
@@ -0,0 +1,12 @@
+[ -n "$include_languages" ] && return 0
+include_languages="$0"
+
+language="$(HEADER Accept-Language)"; language="${language%%[;,._-]*}"
+case "$language" in
+  de) export LC_TIME=de_DE.UTF-8
+      table_date="%A <br/> %_d. %B %Y"
+      ;;
+   *) export LC_TIME=C
+      table_date="%A <br/> %B %_d, %Y"
+      ;;
+esac
diff --git a/poll.sh b/poll.sh
index 7ab0e9d58dea7414449584d78dc0046e9fcb48b9..240a155d26bc5378b6ef8cfff8a23d87466a8642 100644 (file)
--- a/poll.sh
+++ b/poll.sh
@@ -1,6 +1,7 @@
 #!/bin/sh
 
 . "${_EXEC}/comments.sh"
+. "${_EXEC}/languages.sh"
 
 id="$(checkid "${PATH_INFO#/}")"
 file="${_DATA}/${id}"
@@ -74,6 +75,8 @@ table_poll() {
   local edit="$(GET edit)"
   local time date span name yes no maybe yc nc mc
 
+  table_date="${table_date+"%A <br/> %B %_d, %Y"}"
+
   [ "$timelist" ] || return 1
 
   printf '[table .poll [thead\n'
@@ -84,7 +87,7 @@ table_poll() {
       span=0; for time in $timelist; do case $time in
         ${date}*) span=$((span + 1));;
       esac; done
-      date -d "$date" +"[th colspan=\"${span}\" . %A <br/> %B %_d, %Y]";
+      date -d "$date" +"[th colspan=\"${span}\" . ${table_date}]";
     done
     printf '[th]]\n'
   fi