diff options
| author | Simeon Simeonov | 2018-02-26 11:23:00 +0100 |
|---|---|---|
| committer | Simeon Simeonov | 2018-02-26 11:23:00 +0100 |
| commit | 0b3cbf57875fd692e4ba0b336fefa4bee1ed00dc (patch) | |
| tree | af916a30553c78ce9d4f2d8658656a175c5b6921 /macosx/bundle/launcher.sh | |
Initial commit for sylpheed 3.7.0
Diffstat (limited to 'macosx/bundle/launcher.sh')
| -rwxr-xr-x | macosx/bundle/launcher.sh | 170 |
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 | |||
| 3 | if test "x$GTK_DEBUG_LAUNCHER" != x; then | ||
| 4 | set -x | ||
| 5 | fi | ||
| 6 | |||
| 7 | if test "x$GTK_DEBUG_GDB" != x; then | ||
| 8 | EXEC="gdb --args" | ||
| 9 | else | ||
| 10 | EXEC=exec | ||
| 11 | fi | ||
| 12 | |||
| 13 | name=`basename "$0"` | ||
| 14 | tmp="$0" | ||
| 15 | tmp=`dirname "$tmp"` | ||
| 16 | tmp=`dirname "$tmp"` | ||
| 17 | bundle=`dirname "$tmp"` | ||
| 18 | bundle_contents="$bundle"/Contents | ||
| 19 | bundle_res="$bundle_contents"/Resources | ||
| 20 | bundle_lib="$bundle_res"/lib | ||
| 21 | bundle_bin="$bundle_res"/bin | ||
| 22 | bundle_data="$bundle_res"/share | ||
| 23 | bundle_etc="$bundle_res"/etc | ||
| 24 | |||
| 25 | export DYLD_LIBRARY_PATH="$bundle_lib" | ||
| 26 | export XDG_CONFIG_DIRS="$bundle_etc"/xdg | ||
| 27 | export XDG_DATA_DIRS="$bundle_data" | ||
| 28 | export GTK_DATA_PREFIX="$bundle_res" | ||
| 29 | export GTK_EXE_PREFIX="$bundle_res" | ||
| 30 | export GTK_PATH="$bundle_res" | ||
| 31 | |||
| 32 | export GTK2_RC_FILES="$bundle_etc/gtk-2.0/gtkrc" | ||
| 33 | export GTK_IM_MODULE_FILE="$bundle_etc/gtk-2.0/gtk.immodules" | ||
| 34 | export GDK_PIXBUF_MODULE_FILE="$bundle_etc/gtk-2.0/gdk-pixbuf.loaders" | ||
| 35 | export PANGO_RC_FILE="$bundle_etc/pango/pangorc" | ||
| 36 | export PANGO_LIBDIR="$bundle_lib" | ||
| 37 | export PANGO_SYSCONFDIR="$bundle_etc" | ||
| 38 | |||
| 39 | APP=sylpheed | ||
| 40 | I18NDIR="$bundle_data/locale" | ||
| 41 | # Set the locale-related variables appropriately: | ||
| 42 | unset 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. | ||
| 47 | APPLELANGUAGES=`defaults read .GlobalPreferences AppleLanguages | sed -En -e 's/\-/_/' -e 's/Hant/TW/' -e 's/Hans/CN/' -e 's/[[:space:]]*\"?([[:alnum:]_]+)\"?,?/\1/p' ` | ||
| 48 | if 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 | ||
| 74 | fi | ||
| 75 | unset 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. | ||
| 78 | APPLECOLLATION=`defaults read .GlobalPreferences AppleCollationOrder` | ||
| 79 | if 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 | ||
| 83 | fi | ||
| 84 | if test ! -z $APPLECOLLATION; then | ||
| 85 | export LC_COLLATE=$APPLECOLLATION | ||
| 86 | fi | ||
| 87 | unset APPLECOLLATION | ||
| 88 | |||
| 89 | # Continue by attempting to find the Locale preference. | ||
| 90 | APPLELOCALE=`defaults read .GlobalPreferences AppleLocale` | ||
| 91 | |||
| 92 | if 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 | |||
| 97 | elif test -z $LANG -a -f "$I18NDIR/${APPLELOCALE:0:2}/LC_MESSAGES/$APP.mo"; then | ||
| 98 | export LANG="${APPLELOCALE:0:2}" | ||
| 99 | fi | ||
| 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. | ||
| 105 | if 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 | ||
| 126 | else | ||
| 127 | #All efforts have failed, so default to US english | ||
| 128 | export LANG="en_US" | ||
| 129 | export LC_MESSAGES="en_US" | ||
| 130 | fi | ||
| 131 | CURRENCY=`echo $APPLELOCALE | sed -En 's/.*currency=([[:alpha:]]+).*/\1/p'` | ||
| 132 | if 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 | ||
| 145 | fi | ||
| 146 | #No currency value means that the AppleLocale governs: | ||
| 147 | if test -z "$LC_MONETARY"; then | ||
| 148 | LC_MONETARY=${APPLELOCALE:0:5} | ||
| 149 | fi | ||
| 150 | #For Gtk, which only looks at LC_ALL: | ||
| 151 | export LC_ALL=$LC_MESSAGES | ||
| 152 | |||
| 153 | unset APPLELOCALE FILES LOC | ||
| 154 | |||
| 155 | if test -f "$bundle_lib/charset.alias"; then | ||
| 156 | export CHARSETALIASDIR="$bundle_lib" | ||
| 157 | fi | ||
| 158 | |||
| 159 | # Extra arguments can be added in environment.sh. | ||
| 160 | EXTRA_ARGS= | ||
| 161 | if test -f "$bundle_res/environment.sh"; then | ||
| 162 | source "$bundle_res/environment.sh" | ||
| 163 | fi | ||
| 164 | |||
| 165 | # Strip out the argument added by the OS. | ||
| 166 | if /bin/expr "x$1" : '^x-psn_' > /dev/null; then | ||
| 167 | shift 1 | ||
| 168 | fi | ||
| 169 | |||
| 170 | $EXEC "$bundle_contents/MacOS/$name-bin" "$@" $EXTRA_ARGS | ||
