EasyGUI  v0.1
Platform independent GUI Library
Translation engine

String translation engine for widgets. More...

Data Structures

struct  GUI_TRANSLATE_Language_t
 Translation language structure. More...
 
struct  GUI_TRANSLATE_t
 Basic translation structure for internal use. More...
 

Functions

const GUI_Chargui_translate_get (const GUI_Char *src)
 Get translated entry from input string. More...
 
uint8_t gui_translate_setactivelanguage (const GUI_TRANSLATE_Language_t *lang)
 Set currently active language for translated entries. More...
 
uint8_t gui_translate_setsourcelanguage (const GUI_TRANSLATE_Language_t *lang)
 Set source language for translated entries. More...
 

Detailed Description

String translation engine for widgets.

Translation works between source and active languages

Both languages must contain the same array for entries in different languages. When translate is performed, index from source table (if found) is used to return string from active table.

Note
When translation language is changed, all widget must be manually redrawn to get effect
//Create table for English entries
const GUI_Char* languageEnglishEntries[] = {
_GT("Button"),
_GT("Dropdown"),
_GT("Listview"),
_GT("Your string here without translate."),
};
//Create table for German entries
const GUI_Char* languageGermanEntries[] = {
_GT("Taste"), //Translate for "Button"
_GT("Dropdown-Liste"), //Translate for "Dropdown"
_GT("Listenansicht"), //Translate for "Listview"
//Missing translate for "Your string here without translate."
};
//Create English language table
GUI_TRANSLATE_Language_t languageEnglish = {
.Entries = languageEnglishEntries,
.Count = GUI_COUNT_OF(languageEnglishEntries)
};
//Create German language structure
GUI_TRANSLATE_Language_t languageGerman = {
.Entries = languageGermanEntries,
.Count = GUI_COUNT_OF(languageGermanEntries)
};
//Set source and active languages
gui_translate_setsourcelanguage(&languageEnglish); //Translate from this language
gui_translate_setactivelanguage(&languageGerman); //Translate to this language
//Now try to translate
printf("Button: %s\n", gui_translate_get(_GT("Button"))); //Prints: "Button: Taste\n"
printf("Dropdown: %s\n", gui_translate_get(_GT("Dropdown"))); //Prints: "Button: Dropdown-Liste\n"
printf("Listview: %s\n", gui_translate_get(_GT("Listview"))); //Prints: "Button: Listenansicht\n"
printf("Your string here without translate.: %s\n", gui_translate_get(_GT("Your string here without translate."))); //Prints: "Your string here without translate.: Your string here without translate.\n"

Function Documentation

const GUI_Char* gui_translate_get ( const GUI_Char src)

Get translated entry from input string.

Parameters
[in]*srcPointer to GUI_Char string to translate
Return values
Pointerto translated string or source string if translate not found

Scan all entries and return appropriate string

uint8_t gui_translate_setactivelanguage ( const GUI_TRANSLATE_Language_t lang)

Set currently active language for translated entries.

Note
These entries are returned when index matches the source string from source language
Parameters
[in]*langPointer to GUI_TRANSLATE_Language_t structure with translation entries
Return values
1Entries set ok
0Entries were not set
uint8_t gui_translate_setsourcelanguage ( const GUI_TRANSLATE_Language_t lang)

Set source language for translated entries.

Note
These entries are compared with input string to get index for translated value
Parameters
[in]*langPointer to GUI_TRANSLATE_Language_t structure with translation entries
Return values
1Entries set ok
0Entries were not set