Skip to content

Commit

Permalink
add info about currentLocalization property
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii-bodnar committed Feb 3, 2025
1 parent 5230e4e commit baa0c83
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions website/docs/setup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,31 @@ By default, SDK searches for new translation once per application load, but not
By default, the SDK relies on the device locale. To change the SDK target language on the fly regardless of the device locale, use the following method:

```swift
import CrowdinSDK

CrowdinSDK.enableSDKLocalization(true, localization: "<language_code>")
```

Where `<language_code>` is the target language in [ISO 639-1](http://www.loc.gov/standards/iso639-2/php/English_list.php) format.

You can also use the `CrowdinSDK.currentLocalization` property to get or set the current localization language code used by the Crowdin SDK. When you set this property, the SDK triggers a localization download if needed:

```swift
import CrowdinSDK

// Set the current localization to German
CrowdinSDK.currentLocalization = "de"

// ...

// Get the current localization
if let currentLocale = CrowdinSDK.currentLocalization {
print("Current localization: \(currentLocale)")
} else {
print("Using default localization")
}
```

### `addDownloadHandler` closure

The `addDownloadHandler` method allows you to add a closure that will be called every time new localization is downloaded. This can be useful for performing actions such as updating the user interface or processing the newly downloaded localization data:
Expand Down

0 comments on commit baa0c83

Please sign in to comment.