Skip to content

Commit

Permalink
macOS: Fix localization
Browse files Browse the repository at this point in the history
  • Loading branch information
Quentin PARIS committed Dec 24, 2018
1 parent d1a3f87 commit aecbb5d
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 55 deletions.
17 changes: 15 additions & 2 deletions bash/expert/PolShell
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,24 @@

# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

[ "$PLAYONLINUX" = "" ] && exit 0
source "$PLAYONLINUX/lib/sources"

POL_Internal_SetXQuartzDisplay
if [ "$POL_OS" = "Mac" ]; then
cat << EOF > /tmp/playOnMacOpenTerminal
#!/bin/bash
export PLAYONLINUX="$PLAYONLINUX"
source "\$PLAYONLINUX/lib/sources"
$(export)
"\$PLAYONLINUX/bash/polshell"
EOF
chmod +x /tmp/playOnMacOpenTerminal
open -b com.apple.terminal /tmp/playOnMacOpenTerminal
exit 0
fi

[ "$DEBIAN_PACKAGE" = "FALSE" ] && TITLEADD="-T $APPLICATION_TITLE"
"$POL_TERM" $TITLEADD -e "$PLAYONLINUX/bash/polshell"
94 changes: 42 additions & 52 deletions lib/playonlinux.lib
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 551 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# 551 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

# playonlinux.lib
# ---------------
Expand All @@ -32,7 +32,7 @@ build_user_state_directory ()
# Build PlayOnLinux's home directories
# Usage : build_user_state_directory
# Warning ! This function is essential. setupwindow.lib will not work if theses directories are not built

mkdir -p "$POL_USER_ROOT/wineprefix/default/"
mkdir -p "$POL_USER_ROOT/shortcuts/"
mkdir -p "$POL_USER_ROOT/configurations/options/"
Expand All @@ -50,7 +50,7 @@ build_user_state_directory ()
mkdir -p "$POL_USER_ROOT/wine/linux-amd64"
elif [ "$POL_OS" == "FreeBSD" ]; then
mkdir -p "$POL_USER_ROOT/wine/freebsd-x86"
mkdir -p "$POL_USER_ROOT/wine/freebsd-amd64"
mkdir -p "$POL_USER_ROOT/wine/freebsd-amd64"
else
mkdir -p "$POL_USER_ROOT/wine/darwin-x86"
mkdir -p "$POL_USER_ROOT/wine/darwin-amd64"
Expand Down Expand Up @@ -81,7 +81,7 @@ clean_tmp ()
if [ "$(ps ux | grep '[p]ython mainwindow\.py' | wc -l)" -gt 1 ]; then
POL_Debug_Message "PlayOnLinux seems to be already running. Don't cleaning tmp"
return 0
fi
fi
fi
POL_Debug_Message "Cleaning temp directory"
mv "$POL_USER_ROOT/tmp" "$POL_USER_ROOT/tmp$$"
Expand Down Expand Up @@ -128,7 +128,7 @@ POL_Extension_Write ()
# If the entry already exists, it will replace it
# Usage : POL_Extension_Write [KEY] [VALUE]

POL_Debug_Message "Extension write: $1 $2"
POL_Debug_Message "Extension write: $1 $2"
cat "$POL_USER_ROOT/extensions.cfg" 2> /dev/null | grep -v "^$1=" > "$POL_USER_ROOT/tmp/newcfg$$"
echo "$1=$2" >> "$POL_USER_ROOT/tmp/newcfg$$"
mv "$POL_USER_ROOT/tmp/newcfg$$" "$POL_USER_ROOT/extensions.cfg"
Expand Down Expand Up @@ -156,7 +156,7 @@ POL_Config_PrefixWrite ()
{
# Write something to current wine prefix's config file
# Usage : POL_Config_PrefixWrite [KEY] [VALUE]

cat "$WINEPREFIX/playonlinux.cfg" 2> /dev/null | grep -v "^$1=" > "$POL_USER_ROOT/tmp/newcfg$$"
echo "$1=$2" >> "$POL_USER_ROOT/tmp/newcfg$$"
mv "$POL_USER_ROOT/tmp/newcfg$$" "$WINEPREFIX/playonlinux.cfg"
Expand All @@ -166,7 +166,7 @@ POL_Config_PrefixDelete ()
{
# Delete an entry in current wine prefix's config file
# Usage : POL_Config_PrefixDelete [KEY]

cat "$WINEPREFIX/playonlinux.cfg" 2> /dev/null | grep -v "^$1=" > "$POL_USER_ROOT/tmp/newcfg$$"
mv "$POL_USER_ROOT/tmp/newcfg$$" "$WINEPREFIX/playonlinux.cfg"
POL_Debug_Message "Prefix config delete: $1"
Expand All @@ -182,7 +182,7 @@ POL_Config_DosPrefixWrite ()
{
# Write something to current wine prefix's config file
# Usage : POL_Config_DosPrefixWrite [KEY] [VALUE]

cat "$WINEPREFIX/playonlinux_dos.cfg" 2> /dev/null | grep -v "^$1=" > "$POL_USER_ROOT/tmp/newcfg$$"
echo "$1=$2" >> "$POL_USER_ROOT/tmp/newcfg$$"
mv "$POL_USER_ROOT/tmp/newcfg$$" "$WINEPREFIX/playonlinux_dos.cfg"
Expand All @@ -192,7 +192,7 @@ POL_Config_DosPrefixDelete ()
{
# Delete an entry in current wine prefix's config file
# Usage : POL_Config_DosPrefixDelete [KEY]

cat "$WINEPREFIX/playonlinux_dos.cfg" 2> /dev/null | grep -v "^$1=" > "$POL_USER_ROOT/tmp/newcfg$$"
mv "$POL_USER_ROOT/tmp/newcfg$$" "$WINEPREFIX/playonlinux_dos.cfg"
POL_Debug_Message "Dos prefix config delete: $1"
Expand Down Expand Up @@ -221,9 +221,9 @@ POL_OpenShell()
{
# Open a shell in the current prefix environment
# Usage : POL_OpenShell ["shortcut name"]

(cat "$PLAYONLINUX/etc/pol_bash"

if [ "$1" = "" ]
then
echo "export WINEPREFIX=\"$WINEPREFIX\""
Expand Down Expand Up @@ -311,9 +311,9 @@ POL_GPG_auth_script()
# Usage POL_GPG_auth_script [filename]
# Return TRUE if the script is valid
# Return FALSE if the script is not valid

POL_Debug_Message "Checking signature of $1"

POL_GPG_install_key
FILENAME="$1"
GPG=`awk '/^-----BEGIN PGP SIGNATURE-----/ {print NR ; exit 0; }' $FILENAME`
Expand All @@ -335,7 +335,7 @@ POL_Bash ()
{
# Equivalent of "bash" command, except that it checks the signature of the script
# Usage : POL_Bash [script]

local OLD_DIR="$PWD"
if [ "$(POL_GPG_auth_script "$1")" = "TRUE" ]
then
Expand All @@ -358,7 +358,7 @@ POL_Source ()
{
# Equivalent of "source" command, except that it checks the signature of the script
# Usage : POL_Source [script]

local OLD_DIR="$PWD"
if [ "$(POL_GPG_auth_script "$1")" = "TRUE" ]
then
Expand Down Expand Up @@ -388,7 +388,7 @@ make_skeleton()
mkdir -p "$DIRAPP"
mkdir -p "$DIRAPP/Contents/MacOS"
mkdir -p "$DIRAPP/Contents/Resources"

printf "APPL????" > "$DIRAPP/Contents/PkgInfo"
touch "$DIRAPP/Contents/MacOS/playonmac"
chmod +x "$DIRAPP/Contents/MacOS/playonmac"
Expand All @@ -400,7 +400,7 @@ make_standalone_script()

substitute=$(printf "$2" | $SED 's/\//\\\//g' | $SED 's/ /\\ /g') # I like that too
substitute2=$(printf "$2" | $SED 's/\/\//\//g' | $SED 's/\//\\\//g' | $SED 's/ /\\ /g') # I like that too

cat << EOF3 > "$DIRAPP/Contents/MacOS/playonmac"
#!/bin/bash
apple_message()
Expand Down Expand Up @@ -521,12 +521,12 @@ make_icon()
png2icns "$DIRAPP/Contents/Resources/playonmac.icns" "/tmp/icon.png" && success=true
fi
fi
if [ ! "$success" = "true" ]

if [ ! "$success" = "true" ]
then
cp "$PLAYONLINUX/etc/playonmac.icns" "$DIRAPP/Contents/Resources/playonmac.icns"
cp "$PLAYONLINUX/etc/playonmac.icns" "$DIRAPP/Contents/Resources/playonmac.icns"
fi

if [ ! -e "$DIRAPP/Contents/Resources/playonmac.icns" ]
then
cp "$PLAYONLINUX/etc/playonmac.icns" "$DIRAPP/Contents/Resources/playonmac.icns"
Expand All @@ -536,7 +536,7 @@ make_plist()
{
# Make the .plist file for the .app in $DIRAPP
# Usage : make_plist [Long name] [Short name]

cat << EOF > "$DIRAPP/Contents/Info.plist"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
Expand Down Expand Up @@ -606,7 +606,7 @@ CleanLnkDesktop()
{
# Clean Desktop from PlayOnLinux's wine shortcuts
# Usage: CleanLnkDesktop

local WIN_DESKTOP="$(POL_Wine_GetRegValue 'Desktop')"
# Fallback to a sane default?
[[ "$WIN_DESKTOP" =~ C:\\.* ]] || WIN_DESKTOP="C:\\user\\$LOGIN\\Desktop"
Expand Down Expand Up @@ -637,7 +637,7 @@ POL_SetupWindow_AutoApp()
{
# Automatically generate a .app for Mac OS X
# Usage: POL_SetupWindow_AutoApp [Shortcut]

shortname=`echo "$1" | tr -c [[a-zA-Z0-9]\.] '_'`
PACKAGE="$1"
POL_Debug_Message "Making .app $PACKAGE ($shortname)"
Expand Down Expand Up @@ -683,9 +683,9 @@ detect_wineprefix()
{
# Read the wineprefix of a shortcut
# Usage: detect_wineprefix [Shortcut]

local file="$POL_USER_ROOT/shortcuts/$1"
if [ -e "$file" ]; then
if [ -e "$file" ]; then
local prefix=$(grep '^export WINEPREFIX' "$file")
prefix=${prefix:18}
prefix=${prefix//"\""/""}
Expand All @@ -697,15 +697,15 @@ detect_wineversion()
{
# Read the wineversion of a shortcut
# Usage: detect_wineversion [Shortcut]

local WINEPREFIX="$(detect_wineprefix "$1")"
POL_Config_PrefixRead "VERSION"
}
detect_appdir()
{
# Read the appdir of a shortcut
# Usage: detect_appdir [Shortcut]

local file="$POL_USER_ROOT/shortcuts/$1"
if [ -e "$file" ]
then
Expand All @@ -718,7 +718,7 @@ detect_appexec()
{
# Read the program of a shortcut
# Usage: detect_appexec [Shortcut]

local file="$POL_USER_ROOT/shortcuts/$1"
if [ -e "$file" ]
then
Expand All @@ -727,7 +727,7 @@ detect_appexec()
fi
}
clean_wineprefix()
{
{
# Detect if a prefix is still use or not.
# It not, ask the user if he/she wants to delete it
# Usage: clean_wineprefix (--non-interactive) /path/of/the/prefix
Expand All @@ -749,7 +749,7 @@ clean_wineprefix()
[ "$POL_OS" = "Linux" ] && TEST=${wineprefix//".PlayOnLinux/wineprefix/"/""}
[ "$POL_OS" = "FreeBSD" ] && TEST=${wineprefix//".PlayOnBSD/wineprefix/"/""}
[ "$POL_OS" = "Mac" ] && TEST=${wineprefix//"Library/PlayOnMac/wineprefix/"/""}

[ "$TEST" = "" ] && exit
if [ "$TEST" = "$wineprefix" ]
then
Expand Down Expand Up @@ -811,20 +811,10 @@ function VersionLower ()
return 1
}

POL_Internal_SetXQuartzDisplay()
{
if [ ! "$POL_OS" = "Mac" ]; then
return
fi
if [ "$DISPLAY" = "" ]; then
local CDISPLAY="$(find /tmp/ 2> /dev/null|grep 'org.macosforge.xquartz'|tail -n 1)"
export DISPLAY="$CDISPLAY"
fi
}
POL_Internal_KillAll()
{
for WId in $(ps aux | grep $APPLICATION_TITLE | grep bash | awk '{print $2}');
do
for WId in $(ps aux | grep $APPLICATION_TITLE | grep bash | awk '{print $2}');
do
kill $WId
cat << EOF > "$POL_USER_ROOT/configurations/guis/$WId"
MsgIn
Expand All @@ -835,16 +825,16 @@ rm "$POL_USER_ROOT/configurations/guis/$WId" 2> /dev/null
done
}

POL_System_FindPart()
{
POL_System_FindPart()
{
if [ -e "$1" ]; then
df -P "$1" | awk '/^\/dev/ {print $1}' || echo "$1 not found";
df -P "$1" | awk '/^\/dev/ {print $1}' || echo "$1 not found";
fi
}
POL_System_FindMountPoint()
{
POL_System_FindMountPoint()
{
if [ -e "$1" ]; then
df -P "$1" | awk 'NR == 2 {print $6}' || echo "$1 not found";
df -P "$1" | awk 'NR == 2 {print $6}' || echo "$1 not found";
fi
}
POL_System_PartInfo()
Expand All @@ -865,7 +855,7 @@ POL_System_CheckFS()
{
[ "$POL_OS" = "Mac" ] && return 0
[ "$POL_OS" = "FreeBSD" ] && return 0

if [ "$1" = "--just-warning" ]; then
DebugType="POL_Debug_Warning"
shift
Expand Down Expand Up @@ -897,12 +887,12 @@ POL_Restart ()
POL_System_RegisterPID()
{
[ "$POL_PORT" = "0" ] && return
echo "$POL_COOKIE POL_System_RegisterPID $1" | ncs "$POL_HOST" "$POL_PORT"
echo "$POL_COOKIE POL_System_RegisterPID $1" | ncs "$POL_HOST" "$POL_PORT"
}
POL_Config_CheckGL()
{
bash "$PLAYONLINUX/bash/check_gl" "x86"
bash "$PLAYONLINUX/bash/check_gl" "amd64"
bash "$PLAYONLINUX/bash/check_gl" "amd64"
}
POL_Config_Win16()
{
Expand Down
6 changes: 5 additions & 1 deletion python/lib/lng.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ def __init__(self):
else:
languages = os.listdir(Variables.playonlinux_env+'/lang/locale')

langid = wx.LANGUAGE_DEFAULT
if(os.environ["POL_OS"] == "Mac"):
langid = wx.Locale().FindLanguageInfo(os.environ["RLANG"]).Language
else:
langid = wx.LANGUAGE_DEFAULT

if(os.environ["DEBIAN_PACKAGE"] == "TRUE"):
localedir = "/usr/share/locale"
else:
Expand Down

0 comments on commit aecbb5d

Please sign in to comment.