X-Git-Url: https://git.plutz.net/?a=blobdiff_plain;f=handlers%2F10_translations.sh;h=ba44a7f9dc09c4e589962757bfe3f25fa92ebb8b;hb=38e8338380e35f9c3c55c6232121cb7575d5cbfb;hp=da67f8947cb6f1b0bb99ac32762fbb1adb4f8c50;hpb=0d5786afa416aa19fc5c0bedd0dea93532abd34f;p=shellwiki diff --git a/handlers/10_translations.sh b/handlers/10_translations.sh index da67f89..ba44a7f 100755 --- a/handlers/10_translations.sh +++ b/handlers/10_translations.sh @@ -1,5 +1,21 @@ #!/bin/sh +# Copyright 2023 Paul Hänsch +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED “AS IS” AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +# SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR +# IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +_(){ printf %s\\n "$*"; } + # Set LANGUAGE_DEFAULT to enable Plugin [ ! "$LANGUAGE_DEFAULT" ] && return 1 @@ -28,7 +44,13 @@ case ${PATH_INFO} in PATH_INFO="${PATH_INFO%:?*/\[attachment\]}[attachment]" ;; */:?*/\[*\]) - :;; # Default handler, considered valid in most cases + LANGUAGE="${PATH_INFO#*/:}" + LANGUAGE="${LANGUAGE%%/*}" + ;; + */:?*/:?*) + # Accidental double language link, last one stays valid! + REDIRECT "${_BASE}${PATH_INFO%/:?*/:?*}/:${PATH_INFO##*/:}" + ;; */:?*/?*) :;; # Default attachment handler */:?*/) # Faulty URL build @@ -63,4 +85,6 @@ case ${PATH_INFO} in ;; esac +[ -r "${_EXEC}/l10n/${LANGUAGE}.sh" ] && . "${_EXEC}/l10n/${LANGUAGE}.sh" + return 1