I am working on a game that is coded in C++ and I would like to make it possible to change language at runtime. Currently, the language is chosen at compile time by includin
You cannot do it with #include
, that's compile time only. More specifically, that's pre-processor only, which happens before compilation.
To get run-time variation, you'll have to move your translations to a text file (something like xml perhaps, but plain text works too) and set up a system that loads the file at startup to populate the strings in the code that need translation.
This also means all your strings will be dynamically sized at start-up, so the initialization period for the code will increase. But that's the cost of flexibility sometimes.