I apologize if this is a little off topic (its more applscript studio), but since there are so few “language translation” subjects… I had a hard time figuring out internationalization. Searching, I didn’t find much Applescript specific, so here goes:
To add internationalization to your program (beyond the user interface - windows, menus, panels - which I already forgot how to do - but is much easier I recall), there are those nasty text strings we have in our programs :
tell main_win
set contents to contents & “Hi. How are you” & return
set contents to contents & “I am looking for " & some_currency & " in cash.”
end tell
So to internationalize, make a new “Localizable.strings” file in your project under “Resources”. So say I have english as my language in my program. Don’t make it global.
Using the above example (you can use whatever name you want instead of INL_Greeting - maybe you want “greeting_” :
“INL_Greeting” = “Hi. How are you”;
“INL_Search” = "I am looking for ";
“INL_Currency” = " in cash."
Create a new language translation. Select the English “Localization.strings” file and Control-click on English and choose “Show Info”. From the pop-up menu on the right called “Localization & Platforms” select the “Add Localized Variant…” option. Give it a name of “Spanish” - or whatever language you choose.
So in the Spanish translation, we would have (with the assistance of google if need be - and change the encoding to UTF-8 or you will loose those accent marks!):
“INL_Greeting” = “Hola. Como estas”;
“INL_Search” = "Estoy buscando a ";
“INL_Currency” = " dinero."
Save the localization.
So go back to the applescript code. Things need to be slightly changed now:
tell main_win
–set contents to contents & “Hi. How are you” & return
set contents to contents & (localized string “INL_Greeting” from table “Localizable”)
–set contents to contents & "I am looking for " & some_currency
set contents to contents & ((localized string “INL_Search” from table “Localizable”) & some_currency & (localized string “INL_Currency” from table “Localizable”)
end tell
You don’t have to read in a single file - it all gets handled by the OS - just with the “localized string” – whatever its called. You can go to the International pane of “System Preferences” and drag Espanol to the top. Start your program and see it Spanish. Pesky text strings stuck in English - Be GONE!