I would like to implement a multi language menu on my micro-controller, but I don't know how.
I thought of some ideas for structure languages who have more sub structure (English, Slovenian, German, ...), and on sub structure have:
char title[] = "MENU"; //english
But I don't know how access into my structure because in main class I have a function to set language.
Example:
function choose language{
choose language = 1; //english
//choose language = 2; //slovenian
}
Call value from structure
PutChar(language[].title); //before choosing the language 1 English, because now call sub structure English.
I'm assuming you will have all of your text hardcoded. Simply create an array of strings:
const char* const title[] = { "MENU" , "MENI" } ;
And then every access to such an object is done via the language enumerator:
enum
{
english = 0 ,
slovenian = 1 ,
} ;
Enums in C are int, so the above code could be done using macro defines, with the same effect:
#define english 0
#define slovenian 1
Then you just define your variable language, set a language, and print the values.
int language = english ;
puts( title[language] ) ;
language = slovenian ;
puts( title[language] ) ;