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.
|
initialization.
|
||||||
|
|
||||||
Here is an example which should make it more clear: suppose that you have a
|
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
|
static array of strings containing the names of chemical elements, which
|
||||||
translated (note that it is a bad example, really, as wxDateTime already
|
have to be translated. If you write:
|
||||||
can be used to get the localized week day names already). If you write:
|
|
||||||
|
|
||||||
@code
|
@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
|
@endcode
|
||||||
|
|
||||||
The code wouldn't compile because the function calls are forbidden in the
|
The code wouldn't compile because the function calls are forbidden in the
|
||||||
array initializer. So instead you should do this:
|
array initializer. So instead you should do this:
|
||||||
|
|
||||||
@code
|
@code
|
||||||
static const char * const weekdays[] = { wxTRANSLATE("Mon"), ...,
|
static const char * const elements[] = { wxTRANSLATE("Hydrogen"),
|
||||||
wxTRANSLATE("Sun") };
|
wxTRANSLATE("Helium"), ... };
|
||||||
...
|
...
|
||||||
// use wxGetTranslation(weekdays[n])
|
// use wxGetTranslation(elements[n])
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
Note that although the code @b would compile if you simply omit
|
Note that although the code @b would compile if you simply omit
|
||||||
wxTRANSLATE() in the above, it wouldn't work as expected because there
|
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.
|
catalog and wxGetTranslation() wouldn't find them.
|
||||||
|
|
||||||
@return A const wxChar*.
|
@return A const wxChar*.
|
||||||
|
Loading…
Reference in New Issue
Block a user