Hello.
This code is posted on behalf of, and with permission from Yvan Koenig.
I have remade it into a script object which should be easily implemented on a script server.
it gives you the buttons for the display dialog command in the language you use.
These may be of more use than merely for showing the buttons. Some of them are useful with a question mark behind them.
I want to add to this something I read here at macscripter.net that you can have choose file, folder and list dialogs within a Finder tell block to get it localized. I’ll show you how I implemented that below Yvans code.
Enjoy!
-- script for localizing the dialogs were kindly given to my by KOENIG,Yvan.
-- The call chain and any problems that may cause is solely a responsibility of mine.
-- macscripter.net/viewtopic.php?id=33508
script localButtons -- © KOENIG,Yvan
property parent : AppleScript -- REMOVE THIS IF YOU ARE NOT CONFIDENT WITH IT
property Cancel_loc : missing value
property Copy_loc : missing value
property Save_loc : missing value
property Continue_loc : missing value
property Ok_loc : missing value
property Authenticate_loc : missing value
property Skip_loc : missing value
property Delete_loc : missing value
property Eject_loc : missing value
on initializeLocalizationValues()
set localButtons's Cancel_loc to localButtons's getLocalizedString("Finder", "AL1") -- Annuler
set localButtons's Copy_loc to localButtons's getLocalizedCoreString("Finder", "ME2") ” Copy
set localButtons's Save_loc to localButtons's getLocalizedString("Finder", "AL2") -- Enregistrer
set localButtons's Continue_loc to localButtons's getLocalizedString("Finder", "AL3") -- Continuer
set localButtons's Ok_loc to my getLocalizedString("Finder", "AL4") -- OK
set localButtons's Authenticate_loc to localButtons's getLocalizedString("Finder", "AL5") -- Authentifier
set localButtons's Skip_loc to my getLocalizedString("Finder", "AL6") -- Ignorer
set localButtons's Delete_loc to localButtons's getLocalizedString("Finder", "AL7") -- Supprimer
set localButtons's Eject_loc to localButtons's getLocalizedString("Finder", "AL8") -- Éjecter
end initializeLocalizationValues
on getLocalizedString(a, x)
tell application a to return localized string x
end getLocalizedString
on getLocalizedCoreString(a, x)
tell application a to return localized string x from table "LocalizableCore"
end getLocalizedCoreString
end script
property parent : my localButtons -- REMOVE THIS IF YOU ARE NOT CONFIDENT WITH IT
-- THE TWO LINES ARE ONLY FOR NOT HAVING TO SPELL OUT "localButtons" EVERYWHERE A BUTTON IS MENTIONED,
-- AND TO AVOID PREPENDING "localButtons" TO THE CALL "initializeLocalizationValues()".
on run
initializeLocalizationValues()
try
(*
with this code, worlwide
click the button on the left or hit EScape will issue error number -128
*)
display dialog "blah blahblah 1" buttons {Cancel_loc, "Trucmuche"} default button 2
on error errMsg number errNbr
log errMsg & return & errNbr
end try
try
(*
with this code, worlwide
click the button, hit EScape will issue error number -128.
*)
display dialog "blah blahblah 2" buttons {Copy_loc} --default button 1
on error errMsg number errNbr
log errMsg & return & errNbr
end try
try
(*
with this code, worlwide
click the button, hit EScape will issue error number -128
As I un-comment 'default button 1', pressing return will do the same.
*)
display dialog "blah blahblah 2" buttons {Cancel_loc} default button 1
on error errMsg number errNbr
log errMsg & return & errNbr
end try
try
(*
with this code, worlwide
click the button on the left or hit EScape will issue error number -128
*)
display dialog "blah blahblah 4" buttons {Skip_loc, Continue_loc} default button 2 cancel button 1
on error errMsg number errNbr
log errMsg & return & errNbr
end try
try
(*
with this code, worlwide
click the button on the left or hit EScape will issue error number -128
*)
display dialog "blah blahblah 4" buttons {Authenticate_loc, Delete_loc} default button 2 cancel button 1
on error errMsg number errNbr
log errMsg & return & errNbr
end try
try
(*
with this code, worlwide
click the button on the left or hit EScape will issue error number -128
*)
display dialog "blah blahblah 4" buttons {Save_loc, Eject_loc} default button 2 cancel button 1
on error errMsg number errNbr
log errMsg & return & errNbr
end try
end run
An example of obtaining a localized choose from file dialog.
tell application "System Events"
tell application process "Finder"
activate
try
set theScriptLibrary to choose file with prompt "choose the Snippet or Clipping to open or ScriptLibrary to create a load statement for, hold down control key to open ScriptLibrary:" default location (activePath's getPrevPath()) as alias
-- on error e number n
-- display dialog e & " : " & n
end try
end tell
end tell
Best Regards
McUsr