Using Launch Arguments To Test Localizations

A quick tip for switching between localizations when testing. Updated 28-December-2013 to include details on setting the locale

Changing the Language Settings

If you have done any work with localizing an application I am sure you are familiar with changing the language of the simulator or a device from the Settings app:

Changing this setting back and forth between the different languages you need to support is tiresome if you do it manually. Luckily there is a build argument you can use to force the language at runtime.

Forcing the Required Language at Runtime

To force an application to run with a specific localization language you can pass the AppleLanguages argument to the application on launch. The argument takes the desired language as a parameter so to force the language to Spanish you would use the following:

-AppleLanguages (Spanish)

The syntax is a little fussy:

Setting the Required Locale

In addition to setting the language you can also set the locale using the AppleLocale argument:

-AppleLocale es_ES

Setting Launch Arguments

The easiest way to pass launch arguments when running from Xcode is to add them to the scheme. You can edit the current scheme from the Product > Scheme > Edit Scheme menu (or use ⌘< or option-click the Run button).

I find it useful to add an AppleLanguages argument to the Run phase of a scheme for each localization and enable the one I need. For example:

Never Miss A Post

Sign up to get my iOS posts and news direct to your inbox and I'll also send you a PDF of my WWDC Viewing Guide

    Unsubscribe at any time. See privacy policy.

    Archives Categories