Skip to main content
Transform your testing process with: Real Device Features, Company-wide Licences, & App Percy
No Result Found

Set localization options

To test a localized version of your app, you can configure language, locale, and timezone for your Appium tests.

Language

Set Appium’s language capability with an appropriate language code to test localized strings in your app.

If you are using BrowserStack SDK, you can set the following capability within the browserstack.yml file:

Capability Description Values
language Set the language of the app under test. Example: ‘fr’ for french

Example

browserstack.yml
Copy icon Copy

Retrieve your app’s localized strings

To retrieve your app’s localized strings for a particular language, use Appium’s app_strings command.

Map<String, String> appStrings = driver.getAppStringMap(
    "<language_code>"
);
let appStrings = driver.getStrings("<language_code>");
Dictionary<string, object> appStrings = driver.GetAppStringDictionary(
    "<language_code>"
);
$strings = $driver->appStrings("<language_code>");
appStrings = self.driver.app_strings(
    "<language_code>"
)
@driver.app_strings("<language_code>")

Locale

Set Appium’s locale capability with an appropriate country code to display or format data such as dates, time, decimal separators, and calendar according to the specified country’s regional conventions.

Capability Description Values
locale Set locale for iOS and Android. Android: ‘CA’ (country name abbreviation) for french (Canada)
iOS: ‘fr_CA’ (language code and country name abbreviation) for french (Canada)

Example

browserstack.yml
Copy icon Copy

BrowserStack SDK is a plug-n-play solution that takes care of all the integration steps for you. Using the BrowserStack SDK is the recommended integration method for your project. To know more, visit the SDK core concepts page.

Use the following code snippet to set the language:

Capability Description Values
language Set the language of the app under test. Example: ‘fr’ for french

Example

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("language", "Fr");
var capabilities = {
	"language" : "Fr",
}
AppiumOptions capabilities = new AppiumOptions();
Dictionary<string, object> browserstackOptions = new Dictionary<string, object>();
capabilities.AddAdditionalCapability("language", "Fr");
$caps = array(
    "language" => "Fr",
)
desired_cap = {
	"language" : "Fr",
}
capabilities = {
    "language" => "Fr",
}
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setCapability("language", "fr");
var capabilities = {
	'language': 'fr'
}
DesiredCapabilities capability = new DesiredCapabilities();
capability.SetCapability("language", "fr");
$capabilities = new DesiredCapabilities();
$capabilities->setCapability("language", "fr");
desired_cap = {
	'language': 'fr
}
desired_caps = {
    'language': 'fr'
}

Retrieve your app’s localized strings

To retrieve your app’s localized strings for a particular language, use Appium’s app_strings command.

Map<String, String> appStrings = driver.getAppStringMap(
    "<language_code>"
);
let appStrings = driver.getStrings("<language_code>");
Dictionary<string, object> appStrings = driver.GetAppStringDictionary(
    "<language_code>"
);
$strings = $driver->appStrings("<language_code>");
appStrings = self.driver.app_strings(
    "<language_code>"
)
@driver.app_strings("<language_code>")

Locale

Set Appium’s locale capability with an appropriate country code to display or format data such as dates, time, decimal separators, and calendar according to the specified country’s regional conventions.

Capability Description Values
locale Set locale for iOS and Android. Android: ‘CA’ (country name abbreviation) for french (Canada)
iOS: ‘fr_CA’ (language code and country name abbreviation) for french (Canada)

Example

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("locale", "fr_CA");
var capabilities = {
	"locale": "fr_CA"
}
AppiumOptions capabilities = new AppiumOptions();
Dictionary<string, object> browserstackOptions = new Dictionary<string, object>();
capabilities.AddAdditionalCapability("locale", "locale");
$caps = array(
    "lanlocaleguage" => "fr_CA",
)
desired_cap = {
	"locale": "fr_CA"
}
capabilities = {
    "locale" => "Fr_CA",
}
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setCapability("locale", "fr_CA");
var capabilities = {
	'locale': 'fr_CA'
}
DesiredCapabilities capability = new DesiredCapabilities();
capability.SetCapability("locale", "fr_CA");
$capabilities = new DesiredCapabilities();
$capabilities->setCapability("locale", "fr_CA");
desired_cap = {
	'locale': 'fr_CA'
}
desired_caps = {
    'locale': 'fr_CA'
}
  • language and locale change settings at a device level on Android and an app level on iOS

  • To ensure application under test uses localized strings and displays dates, times, and calendar in an appropriate format, pass both language and locale in desired capabilities

  • Language and locale features are only available with a BrowserStack Paid plan. You can check paid plans here.

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback

Is this page helping you?

Yes
No

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback!

Talk to an Expert
Download Copy Check Circle