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)