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
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.
Execute the shell script by running the following command:
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:
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:
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:
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.
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.
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.
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.
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