Multi-Language Translation

This supports multi-language translation for user-facing content. By following the steps outlined below, users can add translations for additional languages to the system.

Translation Implementation Details

Folder Structure

user-service/src/main/resource/db/migration/translation

Steps to Add Translations

Prepare Translation Metadata: Begin by creating a translate.txt file within the translation folder. This file contains metadata for the English language and allows users to map corresponding translations in their desired language. Each line should consist of a key-value pair, where the key represents the English text and the value is the translation in the user's language.

translate.txt

Tablet: ট্যাবলেট
Nutrition: পুষ্টি

insert_culture_values.sql : SQL file containing string literals of the English values. This file serves as a template for inserting translations into the database.

execute_translation.sh: Utilize the provided shell script to automate the translation mapping and insertion process. The script reads data from the translate.txt file and maps the corresponding values against the string literals in the SQL file.

Users are required to provide their PostgreSQL connection details, path to the translate.txt file, and the path to the SQL query file. Once executed, the script inserts the translated data into the user database.

To run the shell script, follow these steps:

Ensure that you have PostgreSQL installed and running.

Navigate to the translation folder.

cd user-service/src/main/resource/db/migration/translation

Execute the shell script by running the following command:

./translate.sh

Follow the prompts to enter your PostgreSQL connection details, the path to the translate.txt file, and the path to the SQL query file.

Multi-Language Translation Implementation for Windows OS

This supports multi-language translation for user-facing content, specifically for Windows OS users. Follow the steps outlined below to configure and execute the translation process.

Translation Implementation Details

Folder Structure

user-service/src/main/resource/db/migration/translation

Steps to Add Translations

Configure Database Connection: Open the execute_translation file located in the windows_script folder. Configure your database connection details and provide the paths for the SQL file and file.

Execute Shell Script: After assigning the corresponding values to the file and updating the database configuration, execute the script in Git Bash. Navigate to the windows_script folder and execute the following command:

./execute_translation

This script will create a temp_script.sql file containing the translated values in SQL script format.

Execute Temporary SQL Script in Windows:

Navigate to the PostgreSQL folder on your desktop/laptop.

Execute the following commands to set the encoding to UTF-8:

SET PGCLIENTENCODING=utf-8
chcp 65001

After setting the encoding, execute the following psql command to execute the temporary SQL script. Replace placeholders (---host ip---, ---port-id---, ---dbname---, ---temp sql script path---) with your actual database connection details and the path to the temporary SQL script:

psql -h ---host ip--- -p ---port-id--- -d ---dbname--- -U postgres -W -f "---temp sql script path---"

Building JSON for Forms with Cultural Translations (Android Changes)

The following explains the procedure for integrating cultural translations (utilizing Bengali language as an example) into JSON structures utilized for the dynamic generation of forms, especially for assessments, screenings, and enrollment. It highlights the significance of integrating cultural values into dynamic form generation systems.

1. Including Cultural Translations in the Base JSON:

The below showcases the general structure of a form generator JSON. To include a language(Bengali) translation for the entire form, add a key-value pair with the key titleCulture and the desired Bengali translation (বায়োডাটা in this example) as the value, specifically for the title field.

{
      "familyOrder": 0,
      "viewType": "CardView",
      "id": "bioData",
      "title": "Bio Data"
}

{
      "familyOrder": 0,
      "viewType": "CardView",
      "id": "bioData",
      "title": "Bio Data",
      "titleCulture": "বায়োডাটা"
}

2. Translating Field Labels and Error Messages:

The example below demonstrates how to include cultural translations within a specific form field's JSON definition. Here, a FirstName field is used. We've added Bengali translations for the following:

  • title - Translated to প্রথম নাম using the titleCulture key.

  • hint - Translated to প্রথম নাম লিখুন using the hintCulture key.

  • cultureErrorMessage - A Bengali error message প্রথম নাম অবশ্যই পূরণ করতে হবে এবং এটি ১ থেকে ১০০ বর্ণের মধ্যে হতে হবে is provided.

{
      "isNotDefault": false,
      "fieldName": "First Name",
      "visibility": "visible",
      "orderId": 1,
      "minLength": 1,
      "errorMessage": "First name is required and must be length of 1 to 100",
      "isSummary": true,
      "title": "First Name",
      "isNeededDefault": true,
      "condition": [],
      "isEnabled": true,
      "hint": "Enter First Name",
      "viewType": "EditText",
      "inputType": 96,
      "id": "firstName",
      "family": "bioData",
      "isMandatory": true,
      "maxLength": 100
}

{
      "isNotDefault": false,
      "fieldName": "First Name",
      "visibility": "visible",
      "orderId": 1,
      "minLength": 1,
      "errorMessage": "First name is required and must be length of 1 to 100",
      "isSummary": true,
      "isNeededDefault": true,
      "title": "First Name",
      "hintCulture": "প্রথম নাম লিখুন",
      "titleCulture": "প্রথম নাম",
      "condition": [],
      "hint": "Enter First Name",
      "isEnabled": true,
      "viewType": "EditText",
      "inputType": 96,
      "id": "firstName",
      "family": "bioData",
      "isMandatory": true,
      "maxLength": 100,
      "cultureErrorMessage": "প্রথম নাম অবশ্যই পূরণ করতে হবে এবং এটি ১ থেকে ১০০ বর্ণের মধ্যে হতে হবে"
 }

3. Translating Spinner Options:

Spinners allow users to choose from a predefined list. The example explains how to incorporate Bengali translations into the JSON for such a field. Here's what's included:

  • titleCulture - Translated to মোবাইল নম্বরের ধরন for the spinner's title.

  • optionsList - Each option within the list has a cultureValue field for the Bengali translation. For instance, "Personal" is translated to ব্যক্তিগত, "Family Member" to পরিবারের সদস հղনা, and "Friend" to বন্ধু.

  • cultureErrorMessage - A Bengali error message অনুগ্রহ করে শ্রেণী নির্বাচন করুন is provided.

{
      "isNotDefault": false,
      "fieldName": "Mobile Number Category",
      "visibility": "visible",
      "orderId": 5,
      "defaultValue": "Personal",
      "errorMessage": "Please select a category",
      "isSummary": false,
      "title": "Mobile Number Category",
      "isNeededDefault": true,
      "condition": [],
      "optionsList": [
        {
          "name": "Personal",
          "id": "Personal"
        },
        {
          "name": "Family Member",
          "id": "Family Member"
        },
        {
          "name": "Friend",
          "id": "Friend"
        }
      ],
      "isEnabled": true,
      "viewType": "Spinner",
      "id": "phoneNumberCategory",
      "family": "bioData",
      "isMandatory": true
}

{
      "isNotDefault": false,
      "fieldName": "Mobile Number Category",
      "visibility": "visible",
      "orderId": 5,
      "defaultValue": "Personal",
      "errorMessage": "Please select a category",
      "isSummary": false,
      "isNeededDefault": true,
      "title": "Mobile Number Category",
      "titleCulture": "মোবাইল নম্বরের ধরন",
      "condition": [],
      "optionsList": [
        {
          "name": "Personal",
          "cultureValue": "ব্যক্তিগত",
          "id": "Personal"
        },
        {
          "name": "Family Member",
          "cultureValue": "পরিবারের সদস্য",
          "id": "Family Member"
        },
        {
          "name": "Friend",
          "cultureValue": "বন্ধু",
          "id": "Friend"
        }
      ],
      "isEnabled": true,
      "viewType": "Spinner",
      "id": "phoneNumberCategory",
      "family": "bioData",
      "isMandatory": true,
      "cultureErrorMessage": "অনুগ্রহ করে শ্রেণী নির্বাচন করুন"
}

4. Translating Radio Button Options:

Similar to spinners, radio buttons allow users to select one option. The example explains how to incorporate Bengali translations into their JSON definition:

  • titleCulture - Translated to লিঙ্গ for the radio button group's title.

  • optionsList - Each option within the list has a cultureValue field for the Bengali translation. For instance, "Male" is translated to পুরুষ, "Female" to মহিলা, and "Non-Binary" to নন-বাইনারী.

  • cultureErrorMessage - A Bengali error message অনুগ্রহ করে লিঙ্গ নির্বাচন করুন is provided.

By following these guidelines, you can create culturally inclusive forms that cater to Bengali users.

{
      "orientation": 0,
      "fieldName": "Gender",
      "visibility": "visible",
      "orderId": 1,
      "errorMessage": "Please select a gender",
      "isSummary": true,
      "title": "Gender",
      "isNeededDefault": true,
      "optionType": "string",
      "condition": [],
      "optionsList": [
        {
          "name": "Male",
          "id": "Male"
        },
        {
          "name": "Female",
          "id": "Female"
        },
        {
          "name": "Non-Binary",
          "id": "Non-Binary"
        }
      ],
      "isEnabled": true,
      "viewType": "RadioGroup",
      "id": "gender",
      "family": "bioMetrics",
      "isMandatory": true
}

{
      "orientation": 0,
      "fieldName": "Gender",
      "visibility": "visible",
      "orderId": 1,
      "errorMessage": "Please select a gender",
      "isSummary": true,
      "isNeededDefault": true,
      "title": "Gender",
      "titleCulture": "লিঙ্গ",
      "optionType": "string",
      "condition": [],
      "optionsList": [
        {
          "name": "Male",
          "cultureValue": "পুরুষ",
          "id": "Male"
        },
        {
          "name": "Female",
          "cultureValue": "মহিলা",
          "id": "Female"
        },
        {
          "name": "Non-Binary",
          "cultureValue": "নন-বাইনারী",
          "id": "Non-Binary"
        }
      ],
      "isEnabled": true,
      "viewType": "RadioGroup",
      "id": "gender",
      "family": "bioMetrics",
      "isMandatory": true,
      "cultureErrorMessage": "অনুগ্রহ করে লিঙ্গ নির্বাচন করুন"
}

Sample Implementation: Bengali Language Translation

As a demonstration of the multi-language translation module, we have implemented translation for the Bengali language. The translation values can be found at the specified path mentioned in the initial documentation.

This serves as a reference for users to understand the process and structure of the translation module.To use this sample as a guide when implementing translations for additional languages.

After updating the translation values of meta tables, it's necessary to restart the Spice service so that the translation data will be visible in the application.

Last updated

@2024 Medtronic LABS