-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy path_gscripts_common.sh
More file actions
64 lines (59 loc) · 1.59 KB
/
_gscripts_common.sh
File metadata and controls
64 lines (59 loc) · 1.59 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
GETTEXT=`which gettext`
DOMAIN="gscripts"
# Possible locale paths:
# * /usr/share/locale (gettext default)
# * $SCRIPT_SOURCE/locale
# * $SCRIPT_SOURCE/gscripts/locale
if [ -z "`ls -R /usr/share/locale | grep $DOMAIN.mo`" ]; then
if [ -n "`ls -R $SCRIPT_SOURCE/gscripts/locale | grep $DOMAIN.mo`" ]; then
export TEXTDOMAINDIR="$SCRIPT_SOURCE/gscripts/locale/"
else
export TEXTDOMAINDIR="$SCRIPT_SOURCE/locale/"
fi
fi
#echo $TEXTDOMAINDIR
function __()
{
ARGS=$@
if [ -z "$GETTEXT" ]; then
printf "$ARGS"
else
LINE="$1"
shift
printf "$(gettext "$DOMAIN" "$LINE")" $@
fi
}
function load_gscripts_config()
{
# Search order:
# $HOME/.config/gscripts/gscripts.conf
# $HOME/.gscripts.conf
# $HOME/.gscripts/gscripts.conf
# /usr/local/share/gscripts/gscripts.default.conf
# /usr/share/gscripts/gscripts.default.conf
# $SCRIPT_SOURCE/gscripts.default.conf
HOME="`echo ~`"
if [ -r "$HOME/.config/gscripts/gscripts.conf" ]
then
. "$HOME/.config/gscripts/gscripts.conf"
elif [ -r "$HOME/.gscripts.conf" ]
then
. "$HOME/.gscripts.conf"
elif [ -r "$HOME/.gscripts/gscripts.conf" ]
then
. "$HOME/.gscripts/gscripts.conf"
elif [ -r "/usr/local/share/gscripts/gscripts.default.conf" ]
then
. "/usr/local/share/gscripts/gscripts.default.conf"
elif [ -r "/usr/share/gscripts/gscripts.default.conf" ]
then
. "/usr/share/gscripts/gscripts.default.conf"
elif [ -r "$SCRIPT_SOURCE/gscripts.default.conf" ]
then
. "$SCRIPT_SOURCE/gscripts.default.conf"
else
echo "Config file not found!"
exit -3
fi
}