Language Localization - KL-Psychological-Methodology/TWatch-2020-ESM GitHub Wiki
Most of the text the participants will see is likely already localized, as it is pulled from config.json. However, some default strings are hard coded, like the word "continue", or the text shown on a notification. These can be localized using a separate file, which needs to be called locale.json, and be placed in the micro-SD card's root directory alongside config.json. This is separate from the study configuration file as this is unlikely to change from study to study, while the configuration file will change, meaning you likely will need to take care of this localization fil only once.
The localization file is a single JSON object containing several keys corresponding to the text elements. The corresponding values are strings of the localized text. Following is an example for a German Localization file.
{
"questionnaire_continue": "Weiter",
"questionnaire_completed": "Sie haben den Fragebogen nun komplett ausgefüllt",
"settings_set_date": "Datum einstellen",
"settings_set_time": "Uhrzeit einstellen",
"settings_back": "Zurück",
"notification": "Bitte füllen Sie den Fragebogen '%s' aus.",
"notification_start": "Beginne Fragebogen"
}
Whenever one of these default text elements should be displayed the device will try to access locale.json, and search for the respective key. If it exists it will use the corresponding value. If it cannot find the file or the key is missing, it will instead use the English default.
Key | Meaning/Occurrence | English Default |
---|---|---|
questionnaire_continue |
The text of the button that advances the questionnaire. | Continue |
questionnaire_completed |
A text message informing the participant that the questionnaire is completed. | Thank you for completing the questionnaire. |
notification |
The text of a notification. Note that this expects one %s to occurr, which will be replaced by the questionnaire name. |
Please fill out the questionnaire "%s" |
notification_start |
The text on the button on a notification allowing the participant to proceed to the questionnaire. | Start Questionnaire |
settings_set_time |
The text of the settings menu option allowing to change the time of day. | Set Time |
settings_set_date |
The text of the settings menu option allowing to change the current date. | Set Date |
settings_back |
The text of the back button in the settings menu. | Back |
Note that the font included in the firmware supports all Basic and Latin Unicode ranges. If you need any other ranges, you need to create a new font file, include it in the source code, and recompile the firmware with the new font.
The font used in the firmware by default is Open Sans. You can download it from the following link, and try if it includes the glyphs you need: https://fonts.google.com/specimen/Open%20Sans
Once you have the font file you want to create the font from, you need to convert it into a format the firmware can use. You can use this converter: https://lvgl.io/tools/fontconverter
Make sure to select the appropriate unicode ranges to be included. The firmware uses two sizes, 16 pixel and 32 pixel, so you will need to create one file for each. We recommend to call these open_sans_16 and open_sans_32, even if you use another font, as the code makes several references to these names. Using these names makes it easier to change.
After downloading you can drop these filen into the src
folder of the source code, replacing the existing files of the same name. If everything went right, then all that's left is to recompile the firmware and upload it to the device.