Skip to content

iOS

iOS uses the system default behavior for localizing user experience. To enable supported language, your application must provide that localization too. Otherwise, the localization will fall back to English.

Info

For additional information on how you can localize your iOS Application, please see the official Apple Documentation.

Changing Localization

To change the existing localization, you can utilize the localization hook localizationHandler provided by the Face SDK. This closure is called every time a string is requested.

To see all the localization keys, look up the FaceSDK.strings file at FaceSDK.framework/FaceSDK.bundle/en.lproj/FaceSDK.strings.

Here is an example of how you can add your own CustomLocalization.strings file and override any existing localization provided by the Face SDK:

FaceSDK.service.localizationHandler = { localizationKey in
    // This will look up localization in `CustomLocalization.strings`.
    let result = NSLocalizedString(localizationKey, tableName: "CustomLocalization", comment: "")

    // Localization found in CustomLocalization.
    if result != localizationKey {
        return result
    }

    // By returning nil we fallback to the default localization provided by SDK.
    return nil
}
RFSFaceSDK.service.localizationHandler = ^NSString * _Nullable(NSString * _Nonnull localizationKey) {
    // This will look up localization in `CustomLocalization.strings`.
    NSString *result = NSLocalizedStringFromTable(localizationKey, @"CustomLocalization", @"");

    // Localization found in CustomLocalization.
    if (![result isEqualToString:localizationKey]) {
        return result;
    }

    // By returning nil we fallback to the default localization provided by SDK.
    return nil;
};

Info

See our Catalog App example for additional insight into the implementation.

Warning

Avoid changing the iOS system language (by using the AppleLanguages pref key) from within your application. This goes against the basic iOS user model for switching languages in the Settings app and uses a preference key that is not documented. At some point in the future, the key name may change and that would break your application.