Localization

The SDK allows localisation of the the following:

  • SDK Error Messages
  • API Messages
  • Entity Field Labels (these can be defined in the Back Office on a per langauge basis)

The following APIs are available for managing the language localization.

getLanguage() :

Returns the current language code (ISO 639-1) used for localised messages

Swift

    do {
        let language = try SDK.getClient.getLanguage()
        // Do something with the language code
    }
    catch (let exception) {
        // Handle error
    }

ObjC


    NSError *error;
    NSString *language = [biidCoreSDK.getClient getLanguage:&error];

    if (error) {
        // Handle error
    } else {
        // Do something with the language code
    }

Documentation

setLanguage() :

Overrides the device’s current or preferred language setting and uses this language for localised content and messages.

Swift

    SDK.getClient.setLanguage(toLanguage: languageCode, onSuccess: {
            // Handle Success
        }, onNoConnection: {
            // Handle no connection Error
        }, onInvalidToken: { (error) in
            // Handle invalid token Error
        }, onClientError: { (error) in
            // Handle client error
    })

ObjC


    [biidCoreSDK.getClient setLanguageToLanguage:languageCode
        onSuccess:^{
            // Handle Success
        }
        onNoConnection:^void() {
            // Handle no connection Error
        }
        onInvalidToken:^void(NSError * _Nonnull error) {
            // Handle invalid token error
        }
        onClientError:^void(NSError * _Nonnull error) {
            // Handle client error
        }
    ];

Notes:

Language localization does not persist between cold launches of an app (the app in which the SDK is integrated). Therefore it is recommended that setLanguage() is called as early as possible in the App’s startup flow.

If setLanguage is not called, the SDK will provide localization based on the device’s current or preferred language.

Setting the language results in the localized content being delivered immediately after the setLanguage() call completes i.e. there is no need to re-authenticate the user.

If the language requested is not available as localized content (in the Back Office, then the content is returned in English (en).

Documentation