OCR Confirmation Screen - Text & Language Customization
Learn how to dynamically configure and localize strings in the OCR Confirmation Screen.
Configuring and Localizing Strings
The strings in the OCR Confirmation screen can be configured and localized by using the configureOCRLocalization API. This API uses a Template JSON object, such as the Sample App's FaceTec_OCR_Customization.json, to define all of the possible OCR data groups, group and field names, and field placeholders.
Using Custom/Modified ID Templates
By default, FaceTec_OCR_Customization.json contains the latest OCR group and field data from FaceTec's ID Templates. If you are using your own custom or modified ID Template, then you will need to update FaceTec_OCR_Customization.json with the new group and field data.
For instance, to change the Friendly Name and Field Description of firstName to Portuguese, you would write the following in FaceTec_OCR_Customization.json:
{
"fieldKey": "firstName",
"fieldFriendlyName": "Nome Próprio",
"uiFieldDescriptionText": "Nome Próprio"
}Setting the SDK Localization
Developers should verify that their Template JSON object supports all of the desired language localizations. Once the locale is determined, developers should call configureOCRLocalization to set the SDK localization to the correct language.
Android Example
try {
InputStream is = context.getAssets().open("FaceTec_OCR_Customization.json");
byte[] buffer = new byte[is.available()];
is.read(buffer);
is.close();
JSONObject ocrLocalizationJSON = new JSONObject(new String(buffer, StandardCharsets.UTF_8));
FaceTecSDK.configureOCRLocalization(ocrLocalizationJSON);
} catch (IOException | JSONException ex) {
// Handle error parsing JSON file
}iOS Example
if let path = Bundle.main.path(forResource: "FaceTec_OCR_Customization", ofType: "json") {
do {
let jsonData = try Data(contentsOf: URL(fileURLWithPath: path), options: .mappedIfSafe)
let jsonObject = try JSONSerialization.jsonObject(with: jsonData, options: .mutableLeaves)
if let jsonDictionary = jsonObject as? Dictionary<String, AnyObject> {
FaceTec.sdk.configureOCRLocalization(dictionary: jsonDictionary)
}
} catch {
// Handle error parsing JSON file
}
}Browser Example
const ocrLocalizationJSON = require("../../../../sample-app-resources/FaceTec_OCR_Customization.json");
FaceTecSDK.configureOCRLocalization(ocrLocalizationJSON);