( Arghh … this forum is sooo unusable, with an iPad. It hides all those icons and the I hit, again, on the ‘answered’ icon! How to make it un-answered?! )
@ Markus: renaming language files would not work with a sandboxed app, right?
Maybe there is a plist somewhere, which can be modified?
One could call these from one’s app, but then again I guess that this is not an option for a sandboxed app (? - Instantiating a shell object and then call defaults … ).
Maybe there are some Cocoa functions for this?
No
Cocoa picks the “best match for language” based on the combination of the users preferred language ordering & whats available as supported localizations
I found an AppleScript which lists the languages available in an app and then relaunches it with the user’s selection.
I added the script to my app and call it from the action event of a pushbutton:
The script:
[code]–Autor: Kudusch
–Licence: CC BY-NC
–set the Application you want to work with
set vInput to “Application Name”
–Path and BundleID of application are safed in variables
try
set vPath to (path to application vInput) as string
set vBundle to bundle identifier of (info for (path to application vInput))
on error
error “You must choose an application!”
end try
set vPath to (path to application vInput) as string
set vBundle to bundle identifier of (info for (path to application vInput))
–check available localizations
tell application “Finder”
set vOut to {}
set vFolder to vPath & “Contents:Resources:” as string as alias
try
set vList to name of every folder in vFolder
on error
error “There are no localizations available!”
end try
set vList to name of every folder in vFolder
set n to 1
repeat while n <= (count items in vList)
set vTr to item n of vList
set AppleScript’s text item delimiters to {"."}
set vTr to every text item in vTr as list
if (count every item of vTr) > 1 and item 2 of vTr = “lproj” then
set AppleScript’s text item delimiters to {""}
set vOut to ((item 1 of vTr as list) & vOut)
end if
set n to n + 1
end repeat
end tell
–user chooses language
set dialog2 to choose from list vOut with prompt “Choose language:”
set vLang to dialog2
if vLang = false then
error number -128
end if
set vLang to item 1 of vLang as text
–language is changed
set vScript to “defaults write " & vBundle & " AppleLanguages '(” & vLang & “)’”
do shell script vScript
tell application vInput to quit
delay 2
tell application vInput to activate
[/code]