Use a better example for wxTRANSLATE
Since even the text itself acknowledged the example is bad, use another example that is not bad.
This commit is contained in:
parent
d3924b7d41
commit
49137ba1e1
@ -466,29 +466,28 @@ public:
|
||||
initialization.
|
||||
|
||||
Here is an example which should make it more clear: suppose that you have a
|
||||
static array of strings containing the weekday names and which have to be
|
||||
translated (note that it is a bad example, really, as wxDateTime already
|
||||
can be used to get the localized week day names already). If you write:
|
||||
static array of strings containing the names of chemical elements, which
|
||||
have to be translated. If you write:
|
||||
|
||||
@code
|
||||
static const char * const weekdays[] = { _("Mon"), ..., _("Sun") };
|
||||
static const char * const elements[] = { _("Hydrogen"), _("Helium"), ... };
|
||||
...
|
||||
// use weekdays[n] as usual
|
||||
// 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:
|
||||
|
||||
@code
|
||||
static const char * const weekdays[] = { wxTRANSLATE("Mon"), ...,
|
||||
wxTRANSLATE("Sun") };
|
||||
static const char * const elements[] = { wxTRANSLATE("Hydrogen"),
|
||||
wxTRANSLATE("Helium"), ... };
|
||||
...
|
||||
// use wxGetTranslation(weekdays[n])
|
||||
// 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 weekday names in the program message
|
||||
would be no translations for the element names in the program message
|
||||
catalog and wxGetTranslation() wouldn't find them.
|
||||
|
||||
@return A const wxChar*.
|
||||
|
Loading…
Reference in New Issue
Block a user