Skip to content
This repository was archived by the owner on Feb 4, 2023. It is now read-only.

Commit 9f0e509

Browse files
committed
Merge branch 'ebourg-master' into develop
2 parents 8ac883e + 62a577b commit 9f0e509

File tree

3 files changed

+71
-26
lines changed

3 files changed

+71
-26
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ ChangeLog
22
---------
33

44
### v1.1.0 (Work-In-Progress)
5+
* Localization of messages (English, German, French) (fixes #27 / PR #30, Thanks to @ebourg for his contribution)
56
* Improve the version of Java reported in the error messages (fixes #28)
67
* Send to java.com when the version of Java installed is too old (fixes #29)
78

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ Whilst developing some Java apps for Mac OS X I was facing the problem of suppor
1515
* Apple Java 1.5/1.6: `/System/Library/Java/JavaVirtualMachines/`
1616
* Oracle JRE 1.7/1.8: `/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/`
1717
* Oracle JDK 1.7/1.8: `/System/Library/Java/JavaVirtualMachines/`
18-
18+
1919
2. Mac Apps built with tools designed for Apple's Java (like Apple's JarBundler or the [ANT task "Jarbundler"](http://informagen.com/JarBundler/)) won't work on Macs with Oracle Java 7 and no Apple Java installed.
2020
* This is because the Apple `JavaApplicationStub` only works for Apple's Java and their `Info.plist` style to store Java properties.
2121
* To support Oracle Java 7 you would need to built a separate App package with Oracles [ANT task "Appbundler"](https://java.net/projects/appbundler).
2222
* Thus you would need the user to know which Java distribution he has installed on his Mac. Not very user friendly...
23-
23+
2424
3. Oracle uses a different syntax to store Java properties in the applications `Info.plist` file. A Java app packaged as a Mac app with Oracles Appbundler also needs a different `JavaApplicationStub` and therefore won't work on systems with Apple's Java...
2525

2626
4. Starting with Mac OS X 10.10 *(Yosemite)*, app packages won't open up anymore if they contain the *deprecated* Plist `Java` dictionary. This isn't confirmed by Apple, but [issue #9](https://github.com/tofi86/universalJavaApplicationStub/issues/9) leads to this assumption:
@@ -76,6 +76,7 @@ If none of these could be found or executed, an applescript error dialog is show
7676

7777
![Error Dialog No Java Found](/docs/java-error.png?raw=true)
7878

79+
Messages are localized and displayed either in English (Default), French or German. Language contributions are very welcome!
7980

8081
What you need to do
8182
-------------------
@@ -92,7 +93,7 @@ Download the latest JarBundler release [from its github repo](https://github.com
9293

9394
:exclamation: **Attention:**
9495
> Using an older version of JarBundler (e.g. [old JarBundler ≤ v2.3](http://informagen.com/JarBundler/) or [new JarBundler ≤ v3.2](https://github.com/UltraMixer/JarBundler)) might result in [issue #9](https://github.com/tofi86/universalJavaApplicationStub/issues/9) *(Mac OS X 10.10 asking to install deprecated Apple JRE 6 instead of using a newer Java version)*
95-
>
96+
>
9697
> If you don't want to care about compatibility issues between OS X and Java versions, make sure to use the [latest JarBundler version ≥ 3.3](https://github.com/UltraMixer/JarBundler/releases)
9798
9899
Then place the `universalJavaApplicationStub` from this repo in your build resources folder and link it in your ANT task (attribute `stubfile`). Don't forget to set the newly introduced `useJavaXKey` option:
@@ -104,7 +105,7 @@ Then place the `universalJavaApplicationStub` from this repo in your build resou
104105
stubfile="${resources.dir}/universalJavaApplicationStub"
105106
useJavaXKey="true"
106107
... >
107-
108+
108109
</jarbundler>
109110
```
110111

@@ -122,7 +123,7 @@ Just place the `universalJavaApplicationStub` from this repo in your build resou
122123
icon="${resources.dir}/icon.icns"
123124
executableName="${resources.dir}/universalJavaApplicationStub"
124125
... >
125-
126+
126127
</appbundler>
127128
```
128129

src/universalJavaApplicationStub

Lines changed: 64 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ if [ $exitcode -eq 0 ]; then
140140

141141
# read the Java WorkingDirectory
142142
JVMWorkDir=`/usr/libexec/PlistBuddy -c "print ${JavaKey}:WorkingDirectory" "${InfoPlistFile}" 2> /dev/null | xargs`
143-
143+
144144
# set Working Directory based upon Plist info
145145
if [[ ! -z ${JVMWorkDir} ]]; then
146146
WorkingDirectory="${JVMWorkDir}"
@@ -212,15 +212,15 @@ else
212212
# replace occurences of $APP_ROOT with its content
213213
JVMOptions=`eval "echo ${JVMOptions}"`
214214

215-
# read the ClassPath in either Array or String style
216-
JVMClassPath_RAW=`/usr/libexec/PlistBuddy -c "print JVMClassPath" "${InfoPlistFile}" 2> /dev/null`
217-
if [[ $JVMClassPath_RAW == *Array* ]] ; then
218-
JVMClassPath=.`/usr/libexec/PlistBuddy -c "print JVMClassPath" "${InfoPlistFile}" 2> /dev/null | grep " " | sed 's/^ */:/g' | tr -d '\n' | xargs`
219-
elif [[ ! -z ${JVMClassPath_RAW} ]] ; then
220-
JVMClassPath=${JVMClassPath_RAW}
221-
else
222-
#default: fallback to OracleJavaFolder
223-
JVMClassPath="${JavaFolder}/*"
215+
# read the ClassPath in either Array or String style
216+
JVMClassPath_RAW=`/usr/libexec/PlistBuddy -c "print JVMClassPath" "${InfoPlistFile}" 2> /dev/null`
217+
if [[ $JVMClassPath_RAW == *Array* ]] ; then
218+
JVMClassPath=.`/usr/libexec/PlistBuddy -c "print JVMClassPath" "${InfoPlistFile}" 2> /dev/null | grep " " | sed 's/^ */:/g' | tr -d '\n' | xargs`
219+
elif [[ ! -z ${JVMClassPath_RAW} ]] ; then
220+
JVMClassPath=${JVMClassPath_RAW}
221+
else
222+
#default: fallback to OracleJavaFolder
223+
JVMClassPath="${JavaFolder}/*"
224224
fi
225225
# expand variables $APP_PACKAGE, $JAVAROOT, $USER_HOME
226226
JVMClassPath=`eval "echo ${JVMClassPath}"`
@@ -235,6 +235,49 @@ else
235235
fi
236236

237237

238+
#
239+
# internationalized messages
240+
#
241+
############################################
242+
243+
LANG=`defaults read -g AppleLocale`
244+
245+
# French localization
246+
if [[ $LANG == fr* ]] ; then
247+
MSG_ERROR_LAUNCHING="Erreur au lancement de '${CFBundleName}'."
248+
MSG_MISSING_MAINCLASS="'MainClass' n'est pas spécifié.\nL'application Java ne peut pas être lancée."
249+
MSG_NO_SUITABLE_JAVA="La version de Java installée sur votre système ne convient pas.\nCe programme nécessite Java"
250+
MSG_JAVA_VERSION_OR_LATER="ou plus tard"
251+
MSG_JAVA_VERSION_LATEST="(dernière mise à jour)"
252+
MSG_NO_SUITABLE_JAVA_CHECK="Merci de bien vouloir installer la version de Java requise."
253+
MSG_INSTALL_JAVA="Java doit être installé sur votre système.\nRendez-vous sur java.com et suivez les instructions d'installation..."
254+
MSG_LATER="Plus tard"
255+
MSG_VISIT_JAVA_DOT_COM="Visiter java.com"
256+
257+
# German localization
258+
elif [[ $LANG == de* ]] ; then
259+
MSG_ERROR_LAUNCHING="FEHLER beim starten von '${CFBundleName}'."
260+
MSG_MISSING_MAINCLASS="Die 'MainClass' ist nicht spezifiziert!\nDie Java-Anwendung kann nicht gestartet werden!"
261+
MSG_NO_SUITABLE_JAVA="Es wurde keine passende Java-Version auf Ihrem System gefunden!\nDieses Programm benötigt Java"
262+
MSG_JAVA_VERSION_OR_LATER="oder neuer"
263+
MSG_JAVA_VERSION_LATEST="(neuste Unterversion)"
264+
MSG_NO_SUITABLE_JAVA_CHECK="Stellen Sie sicher, dass die angeforderte Java-Version installiert ist."
265+
MSG_INSTALL_JAVA="Auf Ihrem System muss die 'Java'-Software installiert sein.\nBesuchen Sie java.com für weitere Installationshinweise."
266+
MSG_LATER="Später"
267+
MSG_VISIT_JAVA_DOT_COM="java.com öffnen"
268+
269+
# English default localization
270+
else
271+
MSG_ERROR_LAUNCHING="ERROR launching '${CFBundleName}'."
272+
MSG_MISSING_MAINCLASS="'MainClass' isn't specified!\nJava application cannot be started!"
273+
MSG_NO_SUITABLE_JAVA="No suitable Java version found on your system!\nThis program requires Java"
274+
MSG_JAVA_VERSION_OR_LATER="or later"
275+
MSG_JAVA_VERSION_LATEST="(latest update)"
276+
MSG_NO_SUITABLE_JAVA_CHECK="Make sure you install the required Java version."
277+
MSG_INSTALL_JAVA="You need to have JAVA installed on your Mac!\nVisit java.com for installation instructions..."
278+
MSG_LATER="Later"
279+
MSG_VISIT_JAVA_DOT_COM="Visit java.com"
280+
fi
238281

239282

240283
#
@@ -244,7 +287,7 @@ fi
244287
function JavaVersionSatisfiesRequirement() {
245288
java_ver=$1
246289
java_req=$2
247-
290+
248291
# e.g. 1.8*
249292
if [[ ${java_req} =~ ^[0-9]\.[0-9]\*$ ]] ; then
250293
java_req_num=${java_req:0:3}
@@ -254,7 +297,7 @@ function JavaVersionSatisfiesRequirement() {
254297
else
255298
return 1
256299
fi
257-
300+
258301
# e.g. 1.8+
259302
elif [[ ${java_req} =~ ^[0-9]\.[0-9]\+$ ]] ; then
260303
java_req_num=`echo ${java_req} | sed -E 's/[[:punct:]]//g'`
@@ -264,15 +307,15 @@ function JavaVersionSatisfiesRequirement() {
264307
else
265308
return 1
266309
fi
267-
310+
268311
# e.g. 1.8
269312
elif [[ ${java_req} =~ ^[0-9]\.[0-9]$ ]] ; then
270313
if [ ${java_ver} == ${java_req} ] ; then
271314
return 0
272315
else
273316
return 1
274317
fi
275-
318+
276319
# not matching any of the above patterns
277320
else
278321
return 2
@@ -303,7 +346,7 @@ oracle_jre_version=`extractJavaMajorVersion "${oracle_jre_plugin}"`
303346
# first check system variable "$JAVA_HOME"
304347
if [ -n "$JAVA_HOME" ] ; then
305348
JAVACMD="$JAVA_HOME/bin/java"
306-
349+
307350
# check for JVMversion requirements
308351
elif [ ! -z ${JVMVersion} ] ; then
309352

@@ -321,11 +364,11 @@ elif [ ! -z ${JVMVersion} ] ; then
321364

322365
else
323366
# display human readable java version (#28)
324-
java_version_hr=`echo ${JVMVersion} | sed -E 's/[0-9]\.([0-9+*]+)/\1/g' | sed 's/+/ or later/' | sed 's/*/ (latest update)/'`
367+
java_version_hr=`echo ${JVMVersion} | sed -E 's/[0-9]\.([0-9+*]+)/ \1/g' | sed "s/+/ ${MSG_JAVA_VERSION_OR_LATER}/" | sed "s/*/ ${MSG_JAVA_VERSION_LATEST}/"`
325368
# display error message with applescript
326-
osascript -e "tell application \"System Events\" to display dialog \"ERROR launching '${CFBundleName}'\n\nNo suitable Java version found on your system!\nThis program requires Java ${java_version_hr}\nMake sure you install the required Java version.\" with title \"${CFBundleName}\" buttons {\" OK \", \"Visit java.com\"} default button \"Visit java.com\" with icon path to resource \"${CFBundleIconFile}\" in bundle (path to me)" \
369+
osascript -e "tell application \"System Events\" to display dialog \"${MSG_ERROR_LAUNCHING}\n\n${MSG_NO_SUITABLE_JAVA}${java_version_hr}.\n${MSG_NO_SUITABLE_JAVA_CHECK}\" with title \"${CFBundleName}\" buttons {\" OK \", \"${MSG_VISIT_JAVA_DOT_COM}\"} default button \"${MSG_VISIT_JAVA_DOT_COM}\" with icon path to resource \"${CFBundleIconFile}\" in bundle (path to me)" \
327370
-e "set response to button returned of the result" \
328-
-e "if response is \"Visit java.com\" then open location \"http://java.com\""
371+
-e "if response is \"${MSG_VISIT_JAVA_DOT_COM}\" then open location \"http://java.com\""
329372
# exit with error
330373
exit 3
331374
fi
@@ -356,7 +399,7 @@ fi
356399
# display error message if MainClassName is empty
357400
if [ -z ${JVMMainClass} ]; then
358401
# display error message with applescript
359-
osascript -e "tell application \"System Events\" to display dialog \"ERROR launching '${CFBundleName}'!\n\n'MainClass' isn't specified!\nJava application cannot be started!\" with title \"${CFBundleName}\" buttons {\" OK \"} default button 1 with icon path to resource \"${CFBundleIconFile}\" in bundle (path to me)"
402+
osascript -e "tell application \"System Events\" to display dialog \"${MSG_ERROR_LAUNCHING}\n\n${MSG_MISSING_MAINCLASS}\" with title \"${CFBundleName}\" buttons {\" OK \"} default button 1 with icon path to resource \"${CFBundleIconFile}\" in bundle (path to me)"
360403
# exit with error
361404
exit 2
362405

@@ -392,9 +435,9 @@ elif [ -f "$JAVACMD" ] && [ -x "$JAVACMD" ] ; then
392435
else
393436

394437
# display error message with applescript
395-
osascript -e "tell application \"System Events\" to display dialog \"ERROR launching '${CFBundleName}'!\n\nYou need to have JAVA installed on your Mac!\nVisit java.com for installation instructions...\" with title \"${CFBundleName}\" buttons {\"Later\", \"Visit java.com\"} default button \"Visit java.com\" with icon path to resource \"${CFBundleIconFile}\" in bundle (path to me)" \
438+
osascript -e "tell application \"System Events\" to display dialog \"${MSG_ERROR_LAUNCHING}\n\n${MSG_INSTALL_JAVA}\" with title \"${CFBundleName}\" buttons {\"${MSG_LATER}\", \"${MSG_VISIT_JAVA_DOT_COM}\"} default button \"${MSG_VISIT_JAVA_DOT_COM}\" with icon path to resource \"${CFBundleIconFile}\" in bundle (path to me)" \
396439
-e "set response to button returned of the result" \
397-
-e "if response is \"Visit java.com\" then open location \"http://java.com\""
440+
-e "if response is \"${MSG_VISIT_JAVA_DOT_COM}\" then open location \"http://java.com\""
398441

399442
# exit with error
400443
exit 1

0 commit comments

Comments
 (0)