summaryrefslogtreecommitdiff
path: root/macosx/bundle/launcher.sh
diff options
context:
space:
mode:
Diffstat (limited to 'macosx/bundle/launcher.sh')
-rwxr-xr-xmacosx/bundle/launcher.sh170
1 files changed, 170 insertions, 0 deletions
diff --git a/macosx/bundle/launcher.sh b/macosx/bundle/launcher.sh
new file mode 100755
index 0000000..67f5051
--- /dev/null
+++ b/macosx/bundle/launcher.sh
@@ -0,0 +1,170 @@
1#!/bin/sh
2
3if test "x$GTK_DEBUG_LAUNCHER" != x; then
4 set -x
5fi
6
7if test "x$GTK_DEBUG_GDB" != x; then
8 EXEC="gdb --args"
9else
10 EXEC=exec
11fi
12
13name=`basename "$0"`
14tmp="$0"
15tmp=`dirname "$tmp"`
16tmp=`dirname "$tmp"`
17bundle=`dirname "$tmp"`
18bundle_contents="$bundle"/Contents
19bundle_res="$bundle_contents"/Resources
20bundle_lib="$bundle_res"/lib
21bundle_bin="$bundle_res"/bin
22bundle_data="$bundle_res"/share
23bundle_etc="$bundle_res"/etc
24
25export DYLD_LIBRARY_PATH="$bundle_lib"
26export XDG_CONFIG_DIRS="$bundle_etc"/xdg
27export XDG_DATA_DIRS="$bundle_data"
28export GTK_DATA_PREFIX="$bundle_res"
29export GTK_EXE_PREFIX="$bundle_res"
30export GTK_PATH="$bundle_res"
31
32export GTK2_RC_FILES="$bundle_etc/gtk-2.0/gtkrc"
33export GTK_IM_MODULE_FILE="$bundle_etc/gtk-2.0/gtk.immodules"
34export GDK_PIXBUF_MODULE_FILE="$bundle_etc/gtk-2.0/gdk-pixbuf.loaders"
35export PANGO_RC_FILE="$bundle_etc/pango/pangorc"
36export PANGO_LIBDIR="$bundle_lib"
37export PANGO_SYSCONFDIR="$bundle_etc"
38
39APP=sylpheed
40I18NDIR="$bundle_data/locale"
41# Set the locale-related variables appropriately:
42unset LANG LC_MESSAGES LC_MONETARY LC_COLLATE
43
44# Has a language ordering been set?
45# If so, set LC_MESSAGES and LANG accordingly; otherwise skip it.
46# First step uses sed to clean off the quotes and commas, to change - to _, and change the names for the chinese scripts from "Hans" to CN and "Hant" to TW.
47APPLELANGUAGES=`defaults read .GlobalPreferences AppleLanguages | sed -En -e 's/\-/_/' -e 's/Hant/TW/' -e 's/Hans/CN/' -e 's/[[:space:]]*\"?([[:alnum:]_]+)\"?,?/\1/p' `
48if test "$APPLELANGUAGES"; then
49 # A language ordering exists.
50 # Test, item per item, to see whether there is an corresponding locale.
51 for L in $APPLELANGUAGES; do
52 #test for exact matches:
53 if test -f "$I18NDIR/${L}/LC_MESSAGES/$APP.mo"; then
54 export LANG=$L
55 break
56 fi
57 #This is a special case, because often the original strings are in US
58 #English and there is no translation file.
59 if test "x$L" == "xen_US"; then
60 export LANG=$L
61 break
62 fi
63 #OK, now test for just the first two letters:
64 if test -f "$I18NDIR/${L:0:2}/LC_MESSAGES/$APP.mo"; then
65 export LANG=${L:0:2}
66 break
67 fi
68 #Same thing, but checking for any english variant.
69 if test "x${L:0:2}" == "xen"; then
70 export LANG=$L
71 break
72 fi;
73 done
74fi
75unset APPLELANGUAGES L
76
77# If we didn't get a language from the language list, try the Collation preference, in case it's the only setting that exists.
78APPLECOLLATION=`defaults read .GlobalPreferences AppleCollationOrder`
79if test -z ${LANG} -a -n $APPLECOLLATION; then
80 if test -f "$I18NDIR/${APPLECOLLATION:0:2}/LC_MESSAGES/$APP.mo"; then
81 export LANG=${APPLECOLLATION:0:2}
82 fi
83fi
84if test ! -z $APPLECOLLATION; then
85 export LC_COLLATE=$APPLECOLLATION
86fi
87unset APPLECOLLATION
88
89# Continue by attempting to find the Locale preference.
90APPLELOCALE=`defaults read .GlobalPreferences AppleLocale`
91
92if test -f "$I18NDIR/${APPLELOCALE:0:5}/LC_MESSAGES/$APP.mo"; then
93 if test -z $LANG; then
94 export LANG="${APPLELOCALE:0:5}"
95 fi
96
97elif test -z $LANG -a -f "$I18NDIR/${APPLELOCALE:0:2}/LC_MESSAGES/$APP.mo"; then
98 export LANG="${APPLELOCALE:0:2}"
99fi
100
101#Next we need to set LC_MESSAGES. If at all possilbe, we want a full
102#5-character locale to avoid the "Locale not supported by C library"
103#warning from Gtk -- even though Gtk will translate with a
104#two-character code.
105if test -n $LANG; then
106#If the language code matches the applelocale, then that's the message
107#locale; otherwise, if it's longer than two characters, then it's
108#probably a good message locale and we'll go with it.
109 if test $LANG == ${APPLELOCALE:0:5} -o $LANG != ${LANG:0:2}; then
110 export LC_MESSAGES=$LANG
111#Next try if the Applelocale is longer than 2 chars and the language
112#bit matches $LANG
113 elif test $LANG == ${APPLELOCALE:0:2} -a $APPLELOCALE ">" ${APPLELOCALE:0:2}; then
114 export LC_MESSAGES=${APPLELOCALE:0:5}
115#Fail. Get a list of the locales in $PREFIX/share/locale that match
116#our two letter language code and pick the first one, special casing
117#english to set en_US
118 elif test $LANG == "en"; then
119 export LC_MESSAGES="en_US"
120 else
121 LOC=`find $PREFIX/share/locale -name $LANG???`
122 for L in $LOC; do
123 export LC_MESSAGES=$L
124 done
125 fi
126else
127#All efforts have failed, so default to US english
128 export LANG="en_US"
129 export LC_MESSAGES="en_US"
130fi
131CURRENCY=`echo $APPLELOCALE | sed -En 's/.*currency=([[:alpha:]]+).*/\1/p'`
132if test "x$CURRENCY" != "x"; then
133#The user has set a special currency. Gtk doesn't install LC_MONETARY files, but Apple does in /usr/share/locale, so we're going to look there for a locale to set LC_CURRENCY to.
134 if test -f /usr/local/share/$LC_MESSAGES/LC_MONETARY; then
135 if test -a `cat /usr/local/share/$LC_MESSAGES/LC_MONETARY` == $CURRENCY; then
136 export LC_MONETARY=$LC_MESSAGES
137 fi
138 fi
139 if test -z "$LC_MONETARY"; then
140 FILES=`find /usr/share/locale -name LC_MONETARY -exec grep -H $CURRENCY {} \;`
141 if test -n "$FILES"; then
142 export LC_MONETARY=`echo $FILES | sed -En 's%/usr/share/locale/([[:alpha:]_]+)/LC_MONETARY.*%\1%p'`
143 fi
144 fi
145fi
146#No currency value means that the AppleLocale governs:
147if test -z "$LC_MONETARY"; then
148 LC_MONETARY=${APPLELOCALE:0:5}
149fi
150#For Gtk, which only looks at LC_ALL:
151export LC_ALL=$LC_MESSAGES
152
153unset APPLELOCALE FILES LOC
154
155if test -f "$bundle_lib/charset.alias"; then
156 export CHARSETALIASDIR="$bundle_lib"
157fi
158
159# Extra arguments can be added in environment.sh.
160EXTRA_ARGS=
161if test -f "$bundle_res/environment.sh"; then
162 source "$bundle_res/environment.sh"
163fi
164
165# Strip out the argument added by the OS.
166if /bin/expr "x$1" : '^x-psn_' > /dev/null; then
167 shift 1
168fi
169
170$EXEC "$bundle_contents/MacOS/$name-bin" "$@" $EXTRA_ARGS