blob: e21c7844d075a8efa18886be612a3493f93daa11 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
#!/bin/sh
set -eu
get_lang() {
# LC_MESSAGES="ll_CC.CODESET@modifier" -> ll_CC, where quotes are
# optional
locale 2>/dev/null |
grep ^LC_MESSAGES |
cut -d. -f1 |
cut -d\" -f2 |
cut -d= -f2
}
locpath() {
lang="$1"
printf '@LOCALEDIR@/%s/LC_MESSAGES/@NAME@.sh' "$lang"
}
ll_CC="$(get_lang)"
ll="$(echo "$ll_CC" | cut -d_ -f1)"
if [ -r "$(locpath "$ll")" ]; then
# shellcheck source=/dev/null
. "$(locpath "$ll")"
fi
if [ -r "$(locpath "$ll_CC")" ]; then
# shellcheck source=/dev/null
. "$(locpath "$ll_CC")"
fi
# locale hierarchy:
# 1. the language+country specific message
# 2. the language specific message
# 3. the default fallback value
|