Localization

Sensibill SDK for iOS and Android comes with a several built-in languages:

  • English (en) - DEFAULT
  • English Canada (en-CA)
  • French Canada (fr-CA)
  • Spanish Spain (es-ES)
  • Spanish United States (es-US)

SDK will be automatically localized to a language from the above list:

  • Based on the preferred language of the host application or the language of the device, provided the host application is localized in that language.
  • By default, the SDK will use English (en) localization.

Host application can also change the localization for the strings of the existing languages, or add a localization on additional languages, as described below.

Preparing for Localization Customization

Prerequisite 1: Obtain the List of Customizable Strings

To obtain the SDK localization resources:

  1. Expand one of the architecture slices (ios-arm64 or ios-arm64_x86_64-simulator) inside the Sensibill.xcframework If you are using Sensibill.framework, expand the iOS/Sensibill.framework folder.

  2. Locate the en.lproj/Localizable.strings file, and open it in Xcode:

    The file contains all the keys used by SDK, orgenized by a section of the SDK where they are used.

    For example, the Capture section, has a "crop" key:

Prerequisite 2: Add an Extrnal Bundle

To customize localization, an external bundle must be added to the SDK.

Follow Using External Bundle instructions to create an external bundle. Make sure the location of the bundle is specified in the SDKConfiguration.shared.externalBundle property of the SDK.

How Localized Strings Are Resolved by SDK
  • First, SDK will attempt to find a localized string in external bundle, specified in SDKConfiguration.shared.externalBundle property.
  • If the value is not specified in and external bundle, SDK will attempt to find the same localized string in the default SDK’s bundle (you can obtain these strings, as explained in Step 1).
  • The application’s main bundle will only be checked if the string cannot be found in SDK’s bundle.

Note: Each attempt described above utilizes NSLocalizedString macro, which will select language’s .lproj, based on NSLocale.preferredLanguage

Updating Localization for a Supported Language

This section applies to the following supported languages:

  • For English - en.lproj
  • For English (Canada) - en-CA.lproj
  • For Spanish (Spain) - es-ES.lproj
  • For English (US) - es-US.lproj
  • For French (Canada) - fr-CA.lproj

If the language you want to customize is not listed, please continue to Adding an Additional Language Support section below.

Steps:

  1. Follow Preparing for Localization Customization section to ensure both prerequisites are fulfilled.
  2. Add an lproj and the Localizable.strings for the language you want to customize into an external bundle you created in Prerequisite 2.
  3. Copy the keys from the list of customizable Strings you obtained in Prerequisite 1 into the new file. You can also copy an entire file.

Example:

To change camera permission button title for english language, we will add the en.lproj/Localizable.strings into external bundle, and will add the following key/value to the new file:

Now, the SDK will display the text “Allow Permission” instead of “Allow Access

Adding the Additional Language Support

If the language is currently not supported by SDK, you can add the localization for that language.

Steps:

  1. Follow Preparing for Localization Customization section to ensure both prerequisites are fulfilled.
  2. Add an lproj and the Localizable.strings for the language you want to customize into an external bundle you created in Prerequisite 2.
  3. Copy all keys from the list of customizable Strings you obtained in Prerequisite 1 into the new file. Provide the values on the language you are adding.

The Sensibill SDK uses String resources to set text content used in native UI. To customize Strings in the SDK:

  1. Add the desired string resource to the host application’s strings.xml file (typically strings.xml in the values folder)
  2. Make sure the added string resource has the same name as the string resource that is to be overridden in the SDK. We can provide specific string key values upon request.
<resources>
    ...
    <!--Sensibill String value to be overridden-->
    <string name="sb__sensibill_string_resource_to_override">My Customized string value</string>
</resources>

Note: For localization, make sure to add the string resource to the string resources file in the correct localized values folder. (ie, values-es/string.xml for Spanish translations)