From 2fa0a232ede0b9986be5a07c5de4239e4c7a67af Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Wed, 27 Jul 2022 13:59:07 +0200 Subject: [PATCH] first attempt of internationalization --- languages.sh | 12 ++++++++++++ poll.sh | 5 ++++- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 languages.sh diff --git a/languages.sh b/languages.sh new file mode 100644 index 0000000..c3649f4 --- /dev/null +++ b/languages.sh @@ -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
%_d. %B %Y" + ;; + *) export LC_TIME=C + table_date="%A
%B %_d, %Y" + ;; +esac diff --git a/poll.sh b/poll.sh index 7ab0e9d..240a155 100644 --- 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
%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
%B %_d, %Y]"; + date -d "$date" +"[th colspan=\"${span}\" . ${table_date}]"; done printf '[th]]\n' fi -- 2.39.2