If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Is there any recommendable practice to spread long _() sentences over several code lines without getting troubles with the Unicode compiler and/or xgettext?
MSVC in Unicode builds complains about strings like:
I thought it was a good way to solve the problem you mention and I didn't get compiler errors. So I checked my code and I realized that currently I am not generating a Unicode build.
I remember having generated Unicode builds with the code like this:
wxString s = _( _T("text 1")
_T("text 2")
_T("text n"));
With no problems. I will try to do some testing and tell you my results.
I've tried this but it's not recognized by xgettext... even using the -kwxGetTranslation option it doesn't 'see' the strings...
Sorry! This morning I didn't do tests with poEdit, I just tried find a solution to compile. I did not take poEdit into account
So, probably hgiritzer answer:
the best practice to write the whole sentence into a single long line of code.
is the best answer for now
I was doing more test this evening but I did not find any better answer! poEdit does recognizes wxGetTranslation (when instructed) but the problem seem to be in the inside _T() macro.
I do not have more ideas. If any one finds a solution, please, post it.
This is my best attempt. It is better than a single long line:
_("This program is free software; you can redistribute it and/or modify it \
under the terms of the GNU General Public License as published by the Free \
Software Foundation; either version 2 of the License, or (at your option) \
any later version.");
The only point to take into account is that continuation lines must start at column 1.
This probably doesn't work because constant and static variables are initialized before the actual code execution starts, so translation files are not loaded yet.
quote]This probably doesn't work because constant and static variables are initialized before the actual code execution starts, so translation files are not loaded yet.[/quote]
Yes, it doesn't work.
My approach to solve this is to initialize all const strings in the object constructor. Something as: