-
Notifications
You must be signed in to change notification settings - Fork 369
Changing Locale and Language
You can change the Language and Locale settings by telling Calabash to launch the app with arguments.
There are three steps to testing Localizations:
- You application needs to be localized for the language and locale you are testing.
- The target device needs to be configured to support the language and locale.
- You must tell Calabash to launch your application with special launch arguments.
You must be responsible for Step 1: Localizing your application.
On physical devices, you must set the language and locale manually. You can get configure your device to support more than one keyboard language and set the preferred language order. This is all done in your Settings.app.
Submit your tests with the --locale
option:
$ test-cloud submit < ARGS > --locale "de"
On simulators, you can tell the simulator to launch in a specific locale with a preferred language.
# Set the simulator language to Swiss German and locale to Swiss French
# Languages use a "-" separator for regional varieties
# Locales use a "_" separator for regional varieties
$ calabash-ios sim locale de-CH fr_CH
We have several example projects where we demonstrate launching the iOS Simulators in different languages and locales.
You can set either the language or locale or both.
module Calabash::Launcher
@@launcher = nil
def self.launcher
@@launcher ||= Calabash::Cucumber::Launcher.new
end
def self.launcher=(launcher)
@@launcher = launcher
end
end
Before do |scenario|
launcher = Calabash::Launcher.launcher
options = {
# Launch with Spanish as the primary language
:args => ["-AppleLanguages", "(es)"]
# Launch with Swiss German as the primary language and
# Swiss French as the locale.
:args => ["-AppleLanguages", "(de-CH)",
"-AppleLocale", "fr_CH"]
# Launch with Russian as the primary language and English
# as the second language.
:args => ["-AppleLanguages", "(ru, en)"]
# Launch with German as the locale
:args => ["-AppleLocale", "de"]
}
launcher.relaunch(options)
launcher.calabash_notify(self)
end
Thanks @yakovsh.
This NSHipster page has examples of other launch arguments: