aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2021-06-21 20:01:08 -0300
committerEuAndreh <eu@euandre.org>2021-06-21 20:15:28 -0300
commitf621613128000d0b89abcf9658c80efdc3b6c38b (patch)
tree406c776e00250ae2a50181ad2b726d6f0e4f3343
parentTODOs.md: Mark #task-717fa8b7-1c92-5766-8872-280ae061bf4b as CANCELLED (diff)
downloadgit-permalink-f621613128000d0b89abcf9658c80efdc3b6c38b.tar.gz
git-permalink-f621613128000d0b89abcf9658c80efdc3b6c38b.tar.xz
src/git-permalink.sh: Use LC_MESSAGES to decide on the language
First, instead of looking at "${LANG:-}" for choosing the language, we now use LC_MESSAGES from the locale(1) command. LC_MESSAGES is the appropriate place to look at, and it inherits the value of $LANG by default, but can be overriden so that the text messages from a program spits out strings from a language, but use everything else from $LANG (such as LC_NUMERIC), like in: LANG=abc LC_MESSAGES=zzz I took this opportunity to look only at the language and country part of the locale, and not at the codeset or modifier (as in ll_CC.CODESET@modifier), so that as long as the language+country is the same, it uses the according message. This addresses the "Maybe it could be less restrictive of country or encoding" comment on
-rwxr-xr-xsrc/git-permalink.sh17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/git-permalink.sh b/src/git-permalink.sh
index d1edbba..f894b62 100755
--- a/src/git-permalink.sh
+++ b/src/git-permalink.sh
@@ -60,14 +60,23 @@ MSG_OPEN=\$MSG_OPEN_$lang
"
}
-case "${LANG:-}" in
- pt_BR.UTF-8*)
+get_lang() {
+ # LC_MESSAGES="ll_CC.CODESET@modifier" -> ll_CC, where quotes are optional
+ locale | \
+ grep LC_MESSAGES | \
+ cut -d. -f1 | \
+ cut -d\" -f2 | \
+ cut -d= -f2
+}
+
+case "$(get_lang)" in
+ pt*)
set_lang PT
;;
- fr_FR.UTF-8*)
+ fr*)
set_lang FR
;;
- eo.UTF-8*)
+ eo*)
set_lang EO
;;
*)