AppleLanguages differs based on OS X version - newer versions return values like cs_CZ, older OS X versions return only cs. This leads to problems in scripts executed in VTE. It seems that AppleLocale always returns the complete value so test it first when setting LANG to mitigate this problem.
In addition, move adding the suffix "UTF-8" to the very end of the script because some parts of the script depend on the value without this suffix. You can view, comment on, or merge this pull request online at:
https://github.com/geany/geany-osx/pull/9
-- Commit Summary --
* Check AppleLocale before AppleLanguages when setting LANG
-- File Changes --
M launcher-gtk2.sh (87) M launcher-gtk3.sh (87)
-- Patch Links --
https://github.com/geany/geany-osx/pull/9.patch https://github.com/geany/geany-osx/pull/9.diff
b4n commented on this pull request.
@@ -66,41 +66,49 @@ I18NDIR="$bundle_data/locale"
# Set the locale-related variables appropriately: unset LANG LC_MESSAGES LC_MONETARY LC_COLLATE
+# Start by attempting to find the Locale preference. +APPLELOCALE=`defaults read .GlobalPreferences AppleLocale` +if test -f "$I18NDIR/${APPLELOCALE:0:5}/LC_MESSAGES/$APP.mo"; then + if test -z $LANG; then
how could `LANG` be non-empty as you has unset it above? And if it's meaningful, shouldn't this be done in both cases?
@@ -66,41 +66,49 @@ I18NDIR="$bundle_data/locale"
# Set the locale-related variables appropriately: unset LANG LC_MESSAGES LC_MONETARY LC_COLLATE
+# Start by attempting to find the Locale preference. +APPLELOCALE=`defaults read .GlobalPreferences AppleLocale` +if test -f "$I18NDIR/${APPLELOCALE:0:5}/LC_MESSAGES/$APP.mo"; then + if test -z $LANG; then + export LANG="${APPLELOCALE:0:5}" + fi +elif test -f "$I18NDIR/${APPLELOCALE:0:2}/LC_MESSAGES/$APP.mo"; then + export LANG="${APPLELOCALE:0:5}"
Might be worth a comment that you mean to keep the territory part yet only check for the language.
@@ -66,41 +66,49 @@ I18NDIR="$bundle_data/locale"
# Set the locale-related variables appropriately: unset LANG LC_MESSAGES LC_MONETARY LC_COLLATE
+# Start by attempting to find the Locale preference. +APPLELOCALE=`defaults read .GlobalPreferences AppleLocale` +if test -f "$I18NDIR/${APPLELOCALE:0:5}/LC_MESSAGES/$APP.mo"; then + if test -z $LANG; then
same
techee commented on this pull request.
@@ -66,41 +66,49 @@ I18NDIR="$bundle_data/locale"
# Set the locale-related variables appropriately: unset LANG LC_MESSAGES LC_MONETARY LC_COLLATE
+# Start by attempting to find the Locale preference. +APPLELOCALE=`defaults read .GlobalPreferences AppleLocale` +if test -f "$I18NDIR/${APPLELOCALE:0:5}/LC_MESSAGES/$APP.mo"; then + if test -z $LANG; then
Yeah, this is just copy-paste from the original code, can be dropped.
techee commented on this pull request.
@@ -66,41 +66,49 @@ I18NDIR="$bundle_data/locale"
# Set the locale-related variables appropriately: unset LANG LC_MESSAGES LC_MONETARY LC_COLLATE
+# Start by attempting to find the Locale preference. +APPLELOCALE=`defaults read .GlobalPreferences AppleLocale` +if test -f "$I18NDIR/${APPLELOCALE:0:5}/LC_MESSAGES/$APP.mo"; then + if test -z $LANG; then + export LANG="${APPLELOCALE:0:5}" + fi +elif test -f "$I18NDIR/${APPLELOCALE:0:2}/LC_MESSAGES/$APP.mo"; then + export LANG="${APPLELOCALE:0:5}"
Yeah. It could also be probably changed to `export LANG="$APPLELOCALE"` as there should never be anything longer in the variable.
@b4n I've decided to go simple and basically removed all the code in the launcher script that guesses the right language settings. We can use what `defaults read .GlobalPreferences AppleLocale` gives us directly and the result will be better and less surprising than what the script does now.
Merged #9 into master.
github-comments@lists.geany.org