3

Manually I just go into the system preferences, change the language ordering, and restart my app so it starts up in the default system language. Then I can run automated tests with the app running in that language.

In the command line, there is a built-in OSX utility languagesetup but this requires sudo and it has to prompt for the new language (i.e. there is no obvious command line option).

I don't know AppleScript well enough to use that but I would be open to using it.

2 Answers 2

4

You can open an application using a different language by adding an -AppleLanguages option:

/Applications/Calendar.app/Contents/MacOS/Calendar -AppleLanguages '(de)'

Another option is to add an AppleLanguages array to the property list of the application:

defaults write -app Calendar AppleLanguages -array de; open -a Calendar

languagesetup just changes the first item in the AppleLanguages array in /Library/Preferences/.GlobalPreferences.plist.

1
  • Launching the application with that flag does exactly what I want.
    – travis1097
    Sep 10, 2013 at 17:16
2

There's no need to change the system default language (for most apps, at least). System Preferences » Language & Text doesn't change the system default language anyway, it's just configuration of your user profile.


The following script writes the list of preferred languages (first German, then English):

defaults write -g AppleLanguages -array de en

Run this, then open your application. Add or remove language IDs as needed.

To list your current language configuration:

$ defaults read -g AppleLanguages
(
    en,
    de
)
1
  • Daniel is right but you might want to "defaults read" the array first and copy all the language codes first so you don't have go back and check each one (if you're looking to test all of them). His sample code will only show english and german in the pref pane top level after written. I am using his settings suggestion in a script to periodically reset the default language to English for students in an English immersion program. (of course add - killall Finder) Thanks, Daniel.
    – user255993
    Sep 20, 2013 at 12:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .