Our thinking


Setting Internationalisation Preferences for OS X in a script

One thing that is a lot harder than it needs to be is managing the internationalisation preferences in OS X from a script, via MCX or via a configuration profile.

For some unknown reason, this is a simple change to make manually in System Preferences, yet in Workgroup Manager and in Profile Manager, there’s no built-in way to manage the region settings or the language settings.

It’s also quite difficult to find any information online on how to automate this setting. Fortunately once you know the right commands, it’s very easy to do.

If you want to run it as a script at first boot, or through Remote Desktop, then it’s just two defaults write commands:

defaults write /Library/Preferences/.GlobalPreferences AppleLocale en_AU
defaults write /Library/Preferences/.GlobalPreferences Country AU

If you’re automating this in a DeployStudio workflow then the script can either be set to run at first boot, or if you want to be able to run it prior to the first boot, then it needs to be changed slightly to

defaults write "$TARGET/Library/Preferences/.GlobalPreferences" AppleLocale en_AU
defaults write "$TARGET/Library/Preferences/.GlobalPreferences" Country AU
Obviously you will change the Locale and the Country codes for your region.
Over on the DeployStudio forums, there’s a more generalised version of this script. which you can pass the language and country codes as arguments to the script, however I prefer to hardcode it as I’m only going to be making and deploying images in Australia for the foreseeable future…
#!/bin/bash
#
# Fix for DeployStudio localization workflow task not setting the country
# properly in rc129.
#
# Script From http://www.deploystudio.com/Forums/viewtopic.php?pid=15061
#
# Arguments: LANGUAGE COUNTRY
# e.g. en AU

if [ ! -z "${DS_LAST_SELECTED_TARGET}" ]; then
    TARGET="/Volumes/${DS_LAST_SELECTED_TARGET}"
elif [ ! -z "${DS_LAST_RESTORED_VOLUME}" ]; then
    TARGET="/Volumes/${DS_LAST_RESTORED_VOLUME}"
fi

lang="$1"
country="$2"
locale="$lang_$country"

defaults write "$TARGET/Library/Preferences/.GlobalPreferences" AppleLocale $locale
defaults write "$TARGET/Library/Preferences/.GlobalPreferences" Country $country

Leave a Reply