Remove false information about static arrays and wxTRANSLATE
It is not forbidden to have function calls in static initializers, and such code compiles fine, contrary to claims made by the text. Explain the real reason why wxTRANSLATE is necessary.
This commit is contained in:
committed by
Václav Slavík
parent
49137ba1e1
commit
9a90816f0b
@@ -475,8 +475,11 @@ public:
|
|||||||
// use elements[n] as usual
|
// use elements[n] as usual
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
The code wouldn't compile because the function calls are forbidden in the
|
The code would compile and run, but there would be no translations for the
|
||||||
array initializer. So instead you should do this:
|
strings because static variables are initialized at a very early stage of
|
||||||
|
program execution; that is, before the locale and paths to message catalog
|
||||||
|
files have been set up.
|
||||||
|
So instead you should do this:
|
||||||
|
|
||||||
@code
|
@code
|
||||||
static const char * const elements[] = { wxTRANSLATE("Hydrogen"),
|
static const char * const elements[] = { wxTRANSLATE("Hydrogen"),
|
||||||
@@ -485,10 +488,10 @@ public:
|
|||||||
// use wxGetTranslation(elements[n])
|
// use wxGetTranslation(elements[n])
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
Note that although the code @b would compile if you simply omit
|
Note that if you simply omit wxTRANSLATE() above, those strings would not
|
||||||
wxTRANSLATE() in the above, it wouldn't work as expected because there
|
be marked for translation, and would therefore not be included in the
|
||||||
would be no translations for the element names in the program message
|
message catalog. Consequently, wxGetTranslation() would not find
|
||||||
catalog and wxGetTranslation() wouldn't find them.
|
translations for them.
|
||||||
|
|
||||||
@return A const wxChar*.
|
@return A const wxChar*.
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user