aboutsummaryrefslogtreecommitdiff
path: root/src/git-permalink.in
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2022-01-15 20:47:18 -0300
committerEuAndreh <eu@euandre.org>2022-01-15 20:55:51 -0300
commit31a7db5bf25c411c61ded0e9de8bc65e9cd2611e (patch)
treefd7c5e94449592ce72ca0870eb104387fb21c9f9 /src/git-permalink.in
parentMakefile: Remove makefile.svg (diff)
downloadgit-permalink-31a7db5bf25c411c61ded0e9de8bc65e9cd2611e.tar.gz
git-permalink-31a7db5bf25c411c61ded0e9de8bc65e9cd2611e.tar.xz
Translate and ship strings in src/locale/*.txt
Diffstat (limited to 'src/git-permalink.in')
-rwxr-xr-xsrc/git-permalink.in42
1 files changed, 40 insertions, 2 deletions
diff --git a/src/git-permalink.in b/src/git-permalink.in
index 94697a3..a8e6477 100755
--- a/src/git-permalink.in
+++ b/src/git-permalink.in
@@ -1,10 +1,17 @@
#!/bin/sh
set -eu
+MSGS=''
+add_msg() {
+ MSGS="$MSGS $1"
+}
+
+
MSG_USAGE="$(cat <<-'EOF'
Usage: git permalink [-phV] FILE [LINENO]
EOF
)"
+add_msg USAGE
MSG_HELP="$(cat <<-'EOF'
Options:
@@ -15,11 +22,13 @@ MSG_HELP="$(cat <<-'EOF'
See "man git-permalink" for more information.
EOF
)"
+add_msg HELP
MSG_MISSING_FILE="$(cat <<-'EOF'
Missing FILE argument.
EOF
)"
+add_msg MISSING_FILE
MSG_UNSUPPORTED_ORIGIN="$(cat <<-'EOF'
Unsupported origin: %s.
@@ -28,22 +37,49 @@ MSG_UNSUPPORTED_ORIGIN="$(cat <<-'EOF'
"man git-permalink" for instructions).
EOF
)"
+add_msg UNSUPPORTED_ORIGIN
MSG_OPEN="$(cat <<-'EOF'
Opening %s
EOF
)"
+add_msg OPEN
#
# End translatable strings
#
-if [ -r '@LIBEXECDIR@/@NAME@/load-locale-messages.sh' ]; then
- . '@LIBEXECDIR@/@NAME@/load-locale-messages.sh'
+
+dump_translatable_strings() {
+ for msg in $MSGS; do
+ eval "echo \"\$MSG_$msg\"" > src/locale/"$msg".en.txt
+ done
+
+ cat <<-'EOF'
+ #!/bin/sh
+ # shellcheck disable=2034
+ set -eu
+
+ EOF
+ for msg in $MSGS; do
+ printf 'MSG_%s="$(cat @LOCALEDIR@/@LANG@/LC_MESSAGES/@NAME@/%s.@LANG@.txt)"\n' \
+ "$msg" "$msg"
+ done
+}
+
+if [ -n "${GIT_PERMALINK_DUMP_TRANSLATABLE_STRINGS:-}" ]; then
+ dump_translatable_strings
+ exit
+fi
+
+
+if [ -r '@LIBEXECDIR@/@NAME@/load-messages.sh' ]; then
+ . '@LIBEXECDIR@/@NAME@/load-messages.sh'
fi
+
#
# Documentation functions
#
@@ -61,6 +97,7 @@ version() {
}
+
#
# Core functions
#
@@ -190,6 +227,7 @@ guess_permalink() {
}
+
#
# Main
#