added fixed german translations
[wmaker-crm.git] / util / wmchlocale.in
bloba9e34d7ae4e700a69939c5c64969d2bac54ce3ab
1 #!/bin/sh
3 # Change locale-dependent settings of WindowMaker.
5 # v0.1 by Jan "judas" Tomka <tomka@oalevice.sk> on Jan 28 2001
7 # v0.2 by Jan "judas" Tomka <tomka@oalevice.sk> on Feb 22 2001
8 # - removed --nodef option
9 # - better error recognizing
10 # - added --test switch like in wsetfont
12 # v0.3 by Jan "judas" Tomka <tomka@oalevice.sk> on May 04 2001
13 # - bad bugs with --test found and corrected
16 PROGRAM=`basename $0`
17 VERSION="0.3"
19 if [ "x$GNUSTEP_USER_ROOT" = "x" ]; then
20 GSDIR="$HOME/GNUstep"
21 else
22 GSDIR="$GNUSTEP_USER_ROOT"
23 if [ ! -d "GSDIR" ]; then
24 echo "GNUSTEP_USER_ROOT variable does not contain path to valid directory..." >/dev/stderr
25 exit 1
28 GLOBALDIR="#pkgdatadir#"
29 LOCALDIR="$GSDIR/Library/WindowMaker"
31 help_msg() {
32 echo -e "\n"\
33 "$PROGRAM, v$VERSION by Jan \"judas\" Tomka\n"\
34 "Syntax:\n"\
35 " $PROGRAM [--auto] [--test] [<new-locale> | default]\n"\
36 "\n"\
37 "<new-locale> locale you want WindowMaker to move to (e.g. ja or default)\n"\
38 "--auto use current locale\n"\
39 "--test don't write anything\n"
40 exit 0
43 if [ $# -eq 0 ]; then
44 help_msg
47 for i in $*; do
48 case $i in
49 --auto)
50 auto="YES";;
51 --test)
52 test="--test";;
54 if [ -z "$new_locale" ]; then
55 new_locale="$i"
56 else
57 echo -e "\nUnrecognized command line argument, run without arguments to see help.\n"
58 exit 1
59 fi;;
60 esac
61 done
62 if [ "$new_locale" = "default" ]; then
63 new_locale=""
64 default="YES"
67 if [ -n "$auto" ] && [ -z "$new_locale" ]; then
68 new_locale=$LANG
69 if [ -z "$new_locale" ]; then
70 new_locale="${LC_ALL%_*}"
74 if [ -z "$new_locale" ]; then
75 if [ -z "$default" ]; then
76 echo -e "\nNo locale is set, using default...\n" >/dev/stderr
78 elif ! (locale -a |grep "^$new_locale$" &>/dev/null); then
79 if [ -z "$auto" ]; then
80 echo -e "\n"\
81 "Locale $new_locale is not supported on your system..."\
82 "\n" >/dev/stderr
83 else
84 echo -e "\n"\
85 "Locale $new_locale currently set is not supported on your system...\n"\
86 "Check your LANG and LC_ALL variables or install your locale support\n"\
87 "\n" >/dev/stderr
89 exit 1
92 echo -n "Setting Window Maker root menu... "
94 if [ -z "$new_locale" ] || [ "$new_locale" = "en" ]; then
95 menu_list="plmenu menu"
96 args="default"
97 else
98 menu_list="plmenu.$new_locale menu.$new_locale plmenu menu"
99 args="--locale=$new_locale"
102 echo -n "Setting Window Maker root menu... "
104 for new_menu in $menu_list; do
105 for wm_dir in $LOCALDIR $GLOBALDIR; do
106 if [ -f "$wm_dir/$new_menu" ]; then
107 if [ -z "$new_locale" ] || ( [ -n "$new_locale" ] && echo "$new_menu" |grep "menu.$new_locale" &>/dev/null ); then
108 echo "success"
109 else
110 echo "fail (copying default)"
112 new_menu_tmp=$new_menu
113 # Set new_menu_tmp to first 4 letters of $new_menu.
114 while [ ${#new_menu_tmp} -gt 4 ]; do
115 new_menu_tmp=${new_menu_tmp%?}
116 done
117 if [ "${new_menu_tmp}" = "menu" ]; then # plain
118 echo "\"$wm_dir/$new_menu\"" >"$GSDIR/Defaults/WMRootMenu"
119 else # proplist
120 cp -f "$wm_dir/$new_menu" "$GSDIR/Defaults/WMRootMenu"
122 any_found="YES"
123 break 2
125 done
126 done
127 if [ -z "$any_found" ]; then
128 echo "fail (no menu found)"
131 echo -n "Setting Window Maker fonts... "
133 if [ -z "$new_locale" ] || [ "$new_locale" = "en" ]; then
134 args="default $nodef"
135 else
136 args="--locale=$new_locale $nodef"
138 if wsetfont "$args" &>/dev/null; then
139 echo "success"
140 else
141 echo -n "fail"
142 if wsetfont default "$test" &>/dev/null; then
143 echo " (setting default)"
144 else
145 echo " (totally)"