Localizing dialog box buttons....

I was told that the dialog box buttons do not change with the OS language, so I wrote my own localization code as follows:

on DisplayMessage(textToDisplay, btnYes, btnNo)
	display dialog textToDisplay buttons {btnYes, btnNo} default button "Yes" with icon caution
	if button returned of result is "No" then error number -128
end DisplayMessage

And it’s called here:

repeat with i from 1 to count langAbbrev
		if SystemLanguage is item i of langAbbrev then
			set textToDisplay to item i of displayLocale
			set displayCompleted to item i of localeCompleted
			set btnYes to item i of buttonYes
			set btnNo to item i of buttonNo
			set btnClose to item i of buttonClose
			exit repeat
		end if
	end repeat

DisplayMessage(textToDisplay, btnYes, btnNo)
	CloseSoftware()
	Deleter(displayCompleted, btnClose)

However, when I change the OS to French, I get garbage characters on my buttons…any ideas?

Thanks and God bless! :slight_smile:

Ben.

Wait! lol I found my error

on DisplayMessage(textToDisplay, btnYes, btnNo)
	display dialog textToDisplay buttons {btnYes, btnNo} default button btnYes with icon caution
	if button returned of result is btnNo then error number -128
end DisplayMessage

Thanks guys! :slight_smile:

Hello

As I am a lazy guy I ask the system to do the job.

tell application "Sherlock"
	set buttonYes to localized string "COOKIE_SECURE"
	set buttonNo to localized string "COOKIE_NOTSECURE"
end tell

tell application "Finder"
	set buttonOK to localized string "AL4"
	set buttonCancel to localized string "AL1"
end tell

Yvan KOENIG (from FRANCE jeudi 17 avril 2008 18:56:11)

Hello

As I am a lazy guy I ask the system to do the job.

tell application "Sherlock"
	set buttonYes to localized string "COOKIE_SECURE"
	set buttonNo to localized string "COOKIE_NOTSECURE"
end tell

tell application "Finder"
	set buttonOK to localized string "AL4"
	set buttonCancel to localized string "AL1"
end tell

If OK Cancel (localized) fit your needs, you may code only:

tell application "Finder" to display dialog "I uses localized buttons!"

Yvan KOENIG (from FRANCE jeudi 17 avril 2008 18:56:11)

Salu Yvan,

I proposed him this way a few days ago, but his boss doesn’t want it

Hello stephanK

It was a long time since the last time I read you.

If I understand well, you asked to the OP that he write localizableStrings.plist files but I am too lazy to do that.
My proposal was just peeking localized strings from files available in all MacOS X systems.

OK/Cancel are available in the Finder.
Yes/No are available in Sherlock (maybe in other apps too).

And my last example was based on the fact that when we call display dialog as well as Chose file, choose folder . inside a tell block “speaking” to a localized application (Finder is one of them), these dialogs are automatically localized according to the language used by the app.

Yvan KOENIG (from FRANCE jeudi 17 avril 2008 20:27:20)