~aleteoryx/muditaos

ref: e6213e94077379e7d1ae6908dc2a6769fa406ccb muditaos/doc/i18n.md -rw-r--r-- 4.1 KiB
e6213e94 — Lucjan Bryndza [EGD-5737] Merge master into experimental 5 years ago

#Internationalization

#File and data structure

#Display language

Currently all the wording used in MuditaOS interface is collected in the form of JSON files which are located in the image/assets/lang folder.

The default fallback file for every language is currently the English version - English.json.

Language file naming pattern should be universal because MuditaOS displays languages based on the file name (without extension) eg. Deutsch.json will be displayed in language settings as Deutsch.

The name of a language file should also be in the language of the created file eg. for English it should be English.json, for Polish Polski.json etc.

The structure of the file is typical for JSON files:

(...)
"common_open": "OPEN",
"common_call": "CALL",
"common_save": "SAVE",
"common_send": "SEND",
(...)

The keys on the left side refer to the values on the right side. These values are later displayed in MuditaOS applications.

#Keyboard input language

The first four values of JSON language files tell MuditaOS, which keyboard input language is the specific language setting using:

"common_kbd_lower": "English_lower",
"common_kbd_upper": "English_upper",
"common_kbd_numeric": "numeric",
"common_kbd_phone": "phone",
(...)

These values are names of JSON files, which are located in the image/assets/profiles folder.

Every language has its own files for upper and lower letters. Here's an example of a working JSON file for English_lower.json:

{
  "filetype": "normal",
  "31": ".,_:;)(?!#/*+",
  "32": "abc",
  "33": "def",
  "41": "ghi",
  "42": "jkl",
  "43": "mno",
  "51": "pqrs",
  "52": "tuv",
  "53": "wxyz",
  "61": "0x0A",
  "62": " ",
  "63": "0x08"
}

The first value declares the type of this file:

  • normal - they are shown in input language settings, user can change it through GUI (e.g. from English to Polish).
  • special - they won't show in input language settings, they can be modified only in code (e.g. numeric keyboard).

Normal-type files will be displayed in settings by their filename (e.g. English_lower will be shown as English). When you add a new input language you should always include files for lower and upper letters for it.

Next key-value pairs includes code of the key (key) and characters available under this key (value).

Files naming pattern should be: <language>_<lower/upper>, eg. correct implementation of Rodian input language should consist of two files: Rodian_lower.json and Rodian_upper.json.

We also distinguish two types of button presses:

  • shortpress - they are used to write letters taken from loaded input language file.
  • longpress - this type of button press is used, when user keeps button pressed for at least 2 seconds and then releases. In text it is used to write numbers.

Example: If you are using English keyboard language for lower letters and press 1 button (keycode 31) and quickly release it, then in SMS textbox a letter will appear. But if you hold this button pressed for at least 2 seconds and then release it, 1 number will appear.

Definition for every key code used in the phone is in the key_codes.hpp file (KeyCodes enum)

#Date and time

MuditaOS follows Linux date to format date and time.

#How to start localizing the interface

  1. Create an issue with the localization you want to start working on. Please use the following issue title scheme: [Language] localization [emoji_flag] eg. Polish localization 🇵🇱. The emoji flag is a small detail that can help other community members in finding the localization they're interested in and helping you out in implementing it. Please make sure that the localization you want to implement has not been already implemented.
  2. Add a i18n label to your new issue on GitHub.
  3. Follow the "Contributing to MuditaOS" article.
  4. As soon as you create a Pull Request with your localization we will review it and add it to the official MuditaOS distribution.