I have a C ++ program with many thousands of string literals in code that need to be translated, for example:
statusBar->Print( "My Message" );
I wrapped string literals with a function that searches for a value in a dictionary and returns the translated version:
statusBar->Print( Translated( "My Message" ) );
The problem is that after profiling, I found that doing this search in all the code is a performance issue. What I would like to do is change the following lines:
static const char * translatedMessage5 = Translated( "My Message" ); statusBar->Print( translatedMessage5 );
But due to the many thousands of instances of this code, it will be error prone (and a bit of a maintenance nightmare). I was hoping I could turn Translated into a macro that declares a static variable in a string. This is clearly not working. Anyone have a better idea?
Brian source share