Multilanguage

Hi there,

i’ve got some question about different languages in my app. I used default as English and German as German language. Is there a possibility to test this settings? Can i start the app with another language?

If you are on a Mac then simply change the system language before starting your app.

hm that is an idea but i dont want to restart the mac all the time :frowning:

You don’t have to restart the Mac, just your app.

When the app starts it checks whiat the system language is set to. So it is not important what the system language actually is, just what it is set to.

Btw how about setting your location in your profile? I akways like when I know to which country/city I’m talking to.

A simpler hack is to swap names the package folders “en.lproj” in Resources folder.
Example swap “en.lproj” with “de.lproj”

Just one word (I always wanted to try that): LangSwitch.

hm the interesting part is, msgboxes dont work with this languages constants o.O

[quote=168981:@Massimo Valle]A simpler hack is to swap names the package folders “en.lproj” in Resources folder.
Example swap “en.lproj” with “de.lproj”[/quote]
No, that is not easier.

Ah wrong alarm, just forget to set the dynamic option … xD

[quote=168981:@Massimo Valle]A simpler hack is to swap names the package folders “en.lproj” in Resources folder.
Example swap “en.lproj” with “de.lproj”[/quote]
No, that is not easier.

Leave the system Preferences open, set the language to Deutsch. Restart your app. It’s in German.

Set the language to French. Restart your app. It’s in French.

Etc.

No need to muck around inside the app bundle.

in OSX you can start your app from Terminal with different language

/Applications/yourApp.app/Contents/MacOS/yourApp -AppleLanguages ‘(en)’

/Applications/yourApp.app/Contents/MacOS/yourApp -AppleLanguages ‘(de)’

Nice for testing an app in different languages:
http://tj-hd.co.uk/en-gb/languageswitcher/

Or (still Mac only) you could add an AppleScript to your app which the user can call from a menu or pushbutton, which allows him to select a language of his choice (Change “Cashbook Pro” to your app name):

[code]–Autor: Kudusch
–Licence: CC BY-NC

–set the Application you want to work with
set vInput to “Cashbook Pro”

–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 “Cashbook Pro 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]

hm it seems that i have to build the app on english now. If i build it on german i got only german language o.o

Have you moved English to the top of the languages?

“default” isn’t a language
it literally means “whatever language your OS is running right now” when you build

If you want to use dynamic constants to localize you should add one for EVERY language you intend to support
So if you expect to support English & German then you should have “default” set to something, and an entry for English & one for German
Then regardless of what platform or language setting you are on when you build you will get a german & english localization

IF however you only have “default” and German and you’re currently running German then you’r app is in German only

Actually, have you added English as a localized language? If not then it will use the languages you have in your order of preference.

The computer does NOT know that your default is in English.

It uses default when it can’t find any of the other languages in your preferred languages list. As German is in your list it uses that when it doesn’t find English.

Windows question: if you have multiple languages installed, and you change the language in the control panel, will the app then use the new language setting or is a restart required? In other words: is the setting important, or the currently running system language?