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

Commit fe19f50

Browse files
committed
[refactoring] display $MSG_NO_SUITABLE_JAVA using 'printf'
1 parent bac21a2 commit fe19f50

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

src/universalJavaApplicationStub

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,6 @@ fi
259259

260260
#
261261
# internationalized messages
262-
#
263262
############################################
264263

265264
LANG=`defaults read -g AppleLocale`
@@ -269,7 +268,7 @@ stubLogger "[Language] $LANG"
269268
if [[ $LANG == fr* ]] ; then
270269
MSG_ERROR_LAUNCHING="Erreur au lancement de '${CFBundleName}'."
271270
MSG_MISSING_MAINCLASS="'MainClass' n'est pas spécifié.\nL'application Java ne peut pas être lancée."
272-
MSG_NO_SUITABLE_JAVA="La version de Java installée sur votre système ne convient pas.\nCe programme nécessite Java"
271+
MSG_NO_SUITABLE_JAVA="La version de Java installée sur votre système ne convient pas.\nCe programme nécessite Java %s."
273272
MSG_JAVA_VERSION_OR_LATER="ou ultérieur"
274273
MSG_JAVA_VERSION_LATEST="(dernière mise à jour)"
275274
MSG_NO_SUITABLE_JAVA_CHECK="Merci de bien vouloir installer la version de Java requise."
@@ -281,7 +280,7 @@ if [[ $LANG == fr* ]] ; then
281280
elif [[ $LANG == de* ]] ; then
282281
MSG_ERROR_LAUNCHING="FEHLER beim Starten von '${CFBundleName}'."
283282
MSG_MISSING_MAINCLASS="Die 'MainClass' ist nicht spezifiziert!\nDie Java-Anwendung kann nicht gestartet werden!"
284-
MSG_NO_SUITABLE_JAVA="Es wurde keine passende Java-Version auf Ihrem System gefunden!\nDieses Programm benötigt Java"
283+
MSG_NO_SUITABLE_JAVA="Es wurde keine passende Java-Version auf Ihrem System gefunden!\nDieses Programm benötigt Java %s."
285284
MSG_JAVA_VERSION_OR_LATER="oder neuer"
286285
MSG_JAVA_VERSION_LATEST="(neuste Unterversion)"
287286
MSG_NO_SUITABLE_JAVA_CHECK="Stellen Sie sicher, dass die angeforderte Java-Version installiert ist."
@@ -293,7 +292,7 @@ elif [[ $LANG == de* ]] ; then
293292
else
294293
MSG_ERROR_LAUNCHING="ERROR launching '${CFBundleName}'."
295294
MSG_MISSING_MAINCLASS="'MainClass' isn't specified!\nJava application cannot be started!"
296-
MSG_NO_SUITABLE_JAVA="No suitable Java version found on your system!\nThis program requires Java"
295+
MSG_NO_SUITABLE_JAVA="No suitable Java version found on your system!\nThis program requires Java %s."
297296
MSG_JAVA_VERSION_OR_LATER="or later"
298297
MSG_JAVA_VERSION_LATEST="(latest update)"
299298
MSG_NO_SUITABLE_JAVA_CHECK="Make sure you install the required Java version."
@@ -448,11 +447,12 @@ elif [ ! -z ${JVMVersion} ] ; then
448447

449448
if [ -z "${JAVACMD}" ] ; then
450449
# display human readable java version (#28)
451-
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}/"`
450+
java_version_hr=$(echo ${JVMVersion} | sed -E 's/^1\.([0-9+*]+)$/ \1/g' | sed "s/+/ ${MSG_JAVA_VERSION_OR_LATER}/" | sed "s/*/ ${MSG_JAVA_VERSION_LATEST}/")
451+
MSG_NO_SUITABLE_JAVA_EXPANDED=$(printf "${MSG_NO_SUITABLE_JAVA}" "${java_version_hr}")
452452
# log exit cause
453-
stubLogger "[EXIT 3] ${MSG_NO_SUITABLE_JAVA}${java_version_hr}"
454-
# display error message with applescript
455-
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)" \
453+
stubLogger "[EXIT 3] ${MSG_NO_SUITABLE_JAVA_EXPANDED}"
454+
# display error message with AppleScript
455+
osascript -e "tell application \"System Events\" to display dialog \"${MSG_ERROR_LAUNCHING}\n\n${MSG_NO_SUITABLE_JAVA_EXPANDED}\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)" \
456456
-e "set response to button returned of the result" \
457457
-e "if response is \"${MSG_VISIT_JAVA_DOT_COM}\" then open location \"http://java.com\""
458458
# exit with error
@@ -507,7 +507,7 @@ stubLogger "[JavaVersion] $(extractJavaVersionString "${JAVACMD}")${JAVACMD_vers
507507
if [ -z ${JVMMainClass} ]; then
508508
# log exit cause
509509
stubLogger "[EXIT 2] ${MSG_MISSING_MAINCLASS}"
510-
# display error message with applescript
510+
# display error message with AppleScript
511511
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)"
512512
# exit with error
513513
exit 2
@@ -556,7 +556,7 @@ elif [ -f "${JAVACMD}" ] && [ -x "${JAVACMD}" ] ; then
556556
else
557557
# log exit cause
558558
stubLogger "[EXIT 1] ${MSG_ERROR_LAUNCHING}"
559-
# display error message with applescript
559+
# display error message with AppleScript
560560
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)" \
561561
-e "set response to button returned of the result" \
562562
-e "if response is \"${MSG_VISIT_JAVA_DOT_COM}\" then open location \"http://java.com\""

0 commit comments

Comments
 (0)