aboutsummaryrefslogtreecommitdiff
path: root/v2/src/bin/coll2path
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2023-04-08 16:20:00 -0300
committerEuAndreh <eu@euandre.org>2023-04-08 21:18:22 -0300
commit6c2cbb02ac4b16ee7b4c37de50403ce604868ec0 (patch)
treeffb2fb30a741a04f89474f64a2e01df3d891cd12 /v2/src/bin/coll2path
parentv2: src/lib/: Unmark things as executable (diff)
downloadeuandre.org-6c2cbb02ac4b16ee7b4c37de50403ce604868ec0.tar.gz
euandre.org-6c2cbb02ac4b16ee7b4c37de50403ce604868ec0.tar.xz
v2: i18n of the collection name, "article" collection in root
Diffstat (limited to '')
-rwxr-xr-xv2/src/bin/coll2path88
1 files changed, 88 insertions, 0 deletions
diff --git a/v2/src/bin/coll2path b/v2/src/bin/coll2path
new file mode 100755
index 0000000..79b2f53
--- /dev/null
+++ b/v2/src/bin/coll2path
@@ -0,0 +1,88 @@
+#!/bin/sh
+set -eu
+
+usage() {
+ cat <<-'EOF'
+ Usage:
+ coll2path LANGUAGE COLLECTION
+ coll2path -h
+ EOF
+}
+
+help() {
+ cat <<-'EOF'
+
+
+ Options:
+ -h, --help show this message
+
+ LANGUAGE in which language to list the collections
+ names for
+ COLLECTION what collection to get the path for
+
+
+ Get the path for the COLLECTION, doing the proper translation
+ on the way, and checking if is "article".
+
+
+ Examples:
+
+ Get the path for "TIL" in portuguese:
+
+ $ coll2path pt til
+ hea/
+
+
+ Get the path for "articles" in english
+
+ $ collections en articles
+
+ EOF
+}
+
+
+for flag in "$@"; do
+ case "$flag" in
+ --)
+ break
+ ;;
+ --help)
+ usage
+ help
+ exit
+ ;;
+ *)
+ ;;
+ esac
+done
+
+while getopts 'h' flag; do
+ case "$flag" in
+ h)
+ usage
+ help
+ exit
+ ;;
+ *)
+ usage >&2
+ exit 2
+ esac
+done
+shift $((OPTIND - 1))
+
+. src/lib.sh
+
+
+LANGUAGE="${1:-}"
+COLLECTION="${2:-}"
+eval "$(assert_arg "$LANGUAGE" 'LANGUAGE')"
+
+# shellcheck source=/dev/null
+. src/lib/commencement."$LANGUAGE".conf
+
+if [ -z "$COLLECTION" ]; then
+ echo "${article_collection_name:-}"
+else
+ NAME="$(eval "echo \"\$${COLLECTION}_collection_name\"")"
+ echo "$NAME${NAME:+/}"
+fi