In the current standard of C++ (C++03), there are too few specifications about text localization and that makes the c++ developer's life harder than usual when working with localized texts. (Certainly the C++0x standard will help here later.)
Assuming the following scenario (which is from real PC-Mac game development cases):
- responsive (real time) application : the application has to minimize non-responsive times to "not noticeable", so speed of execution is important.
- localized texts : displayed texts are localized in more than two languages, potentially more - don't expect a fixed number of languages, should be easily extensible.
- language defined at runtime : the texts should not be compiled in the application (nor having one application per language), you get the choosen language information at the application launch - that implies some kind of text loading.
- cross-platform : the application is be coded with cross-platform in mind (Windows - Linux/Ubuntu - Mac/OSX) so the localized text system have to be cross platform too;
- stand-alone application : the application provides all that is necessary to run it; it won't use any environment lib or require the user to install anything other than the OS (like most games for example).
What are the best practices to manage localized texts in C++ in this kind of application?
I made some little researches last year about that and for instance the only things I'm sure of is that 'you should use std::wstring
or std::basic_string<ABigEnoughType>
to manipulate the texts in the application'. I stopped my searches because I was more working on the "text display" problem (in case of real time 3D) but I guess there are some best practices to manage localized texts in raw C++ than just that and "using Unicode".
So, all best-practices, suggestions and information (cross-platform makes it hard I think) are welcome!