From 9a90816f0b0d3a45e0701d47a7e44259a0163704 Mon Sep 17 00:00:00 2001 From: Lauri Nurmi Date: Thu, 27 Oct 2016 17:38:54 +0300 Subject: [PATCH] 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. --- interface/wx/translation.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/interface/wx/translation.h b/interface/wx/translation.h index 0da0e20c1b..ad7146cd14 100644 --- a/interface/wx/translation.h +++ b/interface/wx/translation.h @@ -475,8 +475,11 @@ public: // use elements[n] as usual @endcode - The code wouldn't compile because the function calls are forbidden in the - array initializer. So instead you should do this: + The code would compile and run, but there would be no translations for the + 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 static const char * const elements[] = { wxTRANSLATE("Hydrogen"), @@ -485,10 +488,10 @@ public: // use wxGetTranslation(elements[n]) @endcode - Note that although the code @b would compile if you simply omit - wxTRANSLATE() in the above, it wouldn't work as expected because there - would be no translations for the element names in the program message - catalog and wxGetTranslation() wouldn't find them. + Note that if you simply omit wxTRANSLATE() above, those strings would not + be marked for translation, and would therefore not be included in the + message catalog. Consequently, wxGetTranslation() would not find + translations for them. @return A const wxChar*.