Home > Back-end >  How, according to the string name (macro) to extract the corresponding macro content
How, according to the string name (macro) to extract the corresponding macro content

Time:09-18


For example,

 # define TIP_DEBUG_FILE_NAME_CN "file name: 
"# define TIP_DEBUG_FILE_NAME_EN "FS File:
"# define TIP_DEBUG_FILE_SIZE_CN "file size:
"# define TIP_DEBUG_FILE_SIZE_EN "FS Size:"



I set a global variable elsewhere
Decision software languages is CN and EN
 int lang=1;//0=en. 1=cn; 




Then I passed to a function, a string is used to exchange for the corresponding macro content
Then, according to the current language function returns the contents of macro TIP_DEBUG_FILE_SIZE_CN or TIP_DEBUG_FILE_SIZE_EN

 String getLangStr (String MSG) 
{
//todo

}



String _str="TIP_DEBUG_FILE_SIZE";

String _val=getLangStr (_str);

//if lang=1, I'm looking forward to this time _val value is "file size:
"




getLangStr function should be how to write, not limited to functions, macros.