Localisation issue for differentiating the resulting script response

Admins/Mods: If you think the thread title is not good, please rename it more appropriately.

I’ve been localising some of my scripts. I looked at one I did just over a year ago and cleaned up my coding a little at same time.

Objective in this project is to send four different language groups to 4 separate language specific forum pages, the remainder go to a generic MacOSX page. Instead of coding 5 different menu options depending on language, I thought it would be more practical to include all within a single menu but a conditional within one of their menu selections. This is where I have struck a hurdle.

Without the additions to this menu the localisations work well. Just the urls are all the same. In a Test account set to either dutch or german, the script gets stuck at the “nl” dutch line with a message that it has not been defined.

display alert (localized string of "FINISHED.") message (localized string of "If any questions or problems, go to the Forums for assistance") as critical buttons {localized string of "Quit", localized string of "Go to website"} default button localized string of "Quit"
set response to button returned of the result

if response is (localized string of "Go to website") then
	
	set SystemLanguage to do shell script "defaults read .GlobalPreferences AppleLanguages | sed -En '/[a-z]{2}/ {s/^[^a-z]*([a-z]{2}).*$/\\1/p ; q ; }'"
	
	if result is "fr" then open location "http://www.xxx/fran-ais/" --- Francais forum webpage
	if result is "nl" then open location "http://www.xxx/nederlands/" --- Dutch forum webpage
	if result is "de" then open location "http://www.xxx/deutsch/" --- German forum webpage
	if result is "es" then open location "http://www.xxx/espa-ol/" --- Spanish forum webpage
	if result is not "fr" or "nl" or "de" or "es" then open location "http://www.xxx/mac-osx/" --- Generic MacOSX forum webpage
	
end if
quit

Can someone tell me what is wrong with this approach?
Is there a better method?
Is the set SystemLanguage to do shell script the wrong approach in this particular case. My last postings were on this similar topic last year.
Is it possible to define the url locations within the localisation file instead of the script?

Model: 2008 macpro
AppleScript: 2.3
Browser: Firefox 16.0.2
Operating System: Mac OS X (10.6)

Hi.

For a start, change all those ‘if result .’ lines to ‘if SystemLanguage .’. There’s no ‘result’ if the French line isn’t executed ” or even if it is! Then for appearance and efficiency, put in a few 'else’s.

display alert (localized string of "FINISHED.") message (localized string of "If any questions or problems, go to the Forums for assistance") as critical buttons {localized string of "Quit", localized string of "Go to website"} default button localized string of "Quit"
set response to button returned of the result

if response is (localized string of "Go to website") then
	
	set SystemLanguage to do shell script "defaults read .GlobalPreferences AppleLanguages | sed -En '/[a-z]{2}/ {s/^[^a-z]*([a-z]{2}).*$/\\1/p ; q ; }'"
	
	if SystemLanguage is "fr" then
		open location "http://www.xxx/fran-ais/" --- Francais forum webpage
	else if SystemLanguage is "nl" then
		open location "http://www.xxx/nederlands/" --- Dutch forum webpage
	else if SystemLanguage is "de" then
		open location "http://www.xxx/deutsch/" --- German forum webpage
	else if SystemLanguage is "es" then
		open location "http://www.xxx/espa-ol/" --- Spanish forum webpage
	else -- SystemLanguage is none of the above. 
		open location "http://www.xxx/mac-osx/" --- Generic MacOSX forum webpage
	end if
	
end if

This should cure the problem you describe, but I haven’t tested the script as a whole.

Thanks for the quick response. That fixed it perfectly thank you. I should have known about the else if … same issue as something else recently. Still learning. :smiley: Since this works i can apply it to the other projects.