]> git.plutz.net Git - shellwiki/blobdiff - handlers/10_translations.sh
Merge commit '6bc502434737d7f08379e79b94fc6fda424ef779'
[shellwiki] / handlers / 10_translations.sh
index da67f8947cb6f1b0bb99ac32762fbb1adb4f8c50..ba44a7f9dc09c4e589962757bfe3f25fa92ebb8b 100755 (executable)
@@ -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