# Locale

Configure locale behavior and override the default locale that Airship uses.

Airship uses the [Locale](https://www.airship.com/docs/reference/glossary/#locale) for various SDK operations. By default, the SDK automatically uses the device's locale settings, but you can configure it to use the user's preferred language or override it programmatically.

## Configuring locale behavior

You can configure how Airship determines the locale by setting the `useUserPreferredLocale` option in your Airship config during [takeOff](https://www.airship.com/docs/developer/sdk-integration/apple/installation/getting-started/#calling-takeoff).

By default, `useUserPreferredLocale` is `false`, and the SDK uses `Locale.autoupdatingCurrent`, which reflects the device's current locale settings. When set to `true`, the SDK uses the first language from the user's preferred languages list (`Locale.preferredLanguages[0]`), which is useful when you want the SDK to match the user's language preference rather than the device's current locale settings.


#### Swift


```swift
var config = AirshipConfig()

// ... other config settings ...

// Use preferred language instead of current locale
config.useUserPreferredLocale = true

try! Airship.takeOff(config)
```



#### Objective-C


```objc
UAConfig *config = [UAConfig config];

// ... other config settings ...

// Use preferred language instead of current locale
config.useUserPreferredLocale = YES;

[UAirship takeOff:config error:&airshipError];
```




## Overriding the locale

You can override the locale programmatically at runtime, which takes precedence over both the configured locale behavior and the device's locale settings.


#### Swift


```swift
Airship.localeManager.currentLocale = Locale(identifier:"de")
```



#### Objective-C


```objc
UAirship.localeManager.currentLocale = 
    [NSLocale localeWithLocaleIdentifier:@"de"];
```




## Clearing the locale override

To remove a locale override and return to using the configured locale behavior:


#### Swift


```swift
Airship.localeManager.clearLocale()
```



#### Objective-C


```objc
[UAirship.localeManager clearLocale];
```




## Getting the current locale

To retrieve the locale that Airship is currently using:


#### Swift


```swift
let airshipLocale = Airship.localeManager.currentLocale
```



#### Objective-C


```objc
NSLocale *airshipLocale = UAirship.localeManager.currentLocale;
```



