Localization Support

Preparation

  1. In the Project Navigator, select your project.
  2. Select your target.
  3. Go to the Build Phases tag.
  4. Under “Copy Bundle Resources”, add UsherAutoSDKLocalizedStrings.bundle.
  5. You can put the bundle file anywhere in your file structure.
  6. Every error.localizedDescription is localized by the locale you set.

Add New Languages

  1. In UsherAutoSDKLocalizedStrings.bundle, create a strings file named in one of the following ways: * [language designator]-[region designator], e.g. en-AU.strings, en-GB.strings, etc. * [language designator]-[script designator], e.g. zh-Hans.strings, zh-Hant.strings, etc. * [language designator].strings, e.g. zh.strings, en.strings, ja.strings, etc.
  2. Make sure UsherAutoSDKLocalizedStrings.bundle is already imported in your target.
  3. Everything should work properly now.

Note: If no specific script or region designator is found, the SDK falls back to [language designator].strings. For example, if en-GB.strings is not found, the SDK uses en.strings. If en.strings is not found, the default English strings are used. You can reference the following links for language, region, and script designators:

You can reference the following links for language, region and script designators:

Set Locale

let locale = Locale(identifier: "en-US")
UsherSDK.setLocale(locale)

Get Locale

let currentLocale = UsherSDK.getLocale()

The default locale is “en-US” if no locale is set.

Get Localized Error Strings

AccountManager.signOut() { error in
    guard error == nil else {
        print("Error: \(error.localizedDescription)")
    }
}

Use the localizedDescription property to get the localized error message from NSError.

Set Localized Strings for Authentication with Biometrics

Set localized strings for enabling sign in by authenticating with biometrics

  1. Set the localized string key on the configuration before the initialization of UsherSDK.
let config = UsherSDKConfiguration(serverUrl: serverURL,
applicationId: "MyApp")

// other configurations...

// The prompt message is configurable. It describes the attempt to enable sign in with biometrics.
// Default is "Authenticate with Biometrics"
config.enableBiometricSignInMessage = "Authenticate with Biometrics"

UsherSDK.initializeWith(configuration: config, completion: completion)

Modify the key-value pairs for all strings files in UsherAutoSDKLocalizedStrings.bundle.

For example, make sure you have the key-value pair (“Authenticate with Biometrics” = “生体認証”;) in the ja.strings file. The key should match the value you set on the enableBiometricSignInMessage of the config object.