• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            Morya

            wxGetTranslation() wxTRANSLATE() wxT() _() _T()

            wxGetTranslation()    wxTRANSLATE()    wxT()    _()    _T()

            我的結(jié)論,wxT()  == _T()  只是為了讓代碼在Unicode和ANSI模式都可以方便的編譯。
            _T() 和 _wxTRANSLATE() 宏 是為了翻譯需要。平時使用 _T() 就可以,但是某些特殊的初始化無法使用 _T() 就需要用到 _wxTRANSLATE() 。


            ::wxGetTranslation()

            const wxChar * wxGetTranslation(const wxChar* str, const wxChar* domain = NULL)

            const wxChar * wxGetTranslation(const wxChar* str, const wxChar* strPlural, size_t n, const wxChar* domain = NULL)

            This function returns the translation of string str in the current locale. If the string is not found in any of the loaded message catalogs (see internationalization overview), the original string is returned. In debug build, an error message is logged -- this should help to find the strings which were not yet translated. If domain is specified then only that domain/catalog is searched for a matching string. As this function is used very often, an alternative (and also common in Unix world) syntax is provided: the _() macro is defined to do the same thing as wxGetTranslation.

            The second form is used when retrieving translation of string that has different singular and plural form in English or different plural forms in some other language. It takes two extra arguments: as above, str parameter must contain the singular form of the string to be converted and is used as the key for the search in the catalog. The strPlural parameter is the plural form (in English). The parameter n is used to determine the plural form. If no message catalog is found str is returned if 'n == 1', otherwise strPlural.

            See GNU gettext manual for additional information on plural forms handling. For a shorter alternative see the wxPLURAL() macro.

            Both versions call wxLocale::GetString.

            Note that this function is not suitable for literal strings in Unicode builds, since the literal strings must be enclosed into _T() or wxT macro which makes them unrecognised by xgettext, and so they are not extracted to the message catalog. Instead, use the _() and wxPLURAL macro for all literal strings.


             

            wxT()

            wxChar wxT(char ch)

            const wxChar * wxT(const char *s)

            wxT() is a macro which can be used with character and string literals (in other words, 'x' or "foo") to automatically convert them to Unicode in Unicode build configuration. Please see the Unicode overview for more information.

            This macro is simply returns the value passed to it without changes in ASCII build. In fact, its definition is:

            #ifdef UNICODE
            #define wxT(x) L ## x
            #else // !Unicode
            #define wxT(x) x
            #endif

            wxTRANSLATE()

            const wxChar * wxTRANSLATE(const char *s)

            This macro doesn't do anything in the program code -- it simply expands to the value of its argument (except in Unicode build where it is equivalent to wxT which makes it unnecessary to use both wxTRANSLATE and wxT with the same string which would be really unreadable).

            However it does have a purpose and it is to mark the literal strings for the extraction into the message catalog created by xgettext program. Usually this is achieved using _() but that macro not only marks the string for extraction but also expands into a wxGetTranslation function call which means that it cannot be used in some situations, notably for static array 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 const wxChar * const weekdays[] = { _("Mon"), ..., _("Sun") };
            ...
            // use weekdays[n] as usual
            the code wouldn't compile because the function calls are forbidden in the array initializer. So instead you should do

            static const wxChar * const weekdays[] = { wxTRANSLATE("Mon"), ..., wxTRANSLATE("Sun") };
            ...
            // use wxGetTranslation(weekdays[n])
            here.

            Note that although the code 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 catalog and wxGetTranslation wouldn't find them.


            _()

            const wxChar * _(const char *s)

            This macro expands into a call to wxGetTranslation function, so it marks the message for the extraction by xgettext just as wxTRANSLATE does, but also returns the translation of the string for the current locale during execution.

            Don't confuse this macro with _T()!


            _T()

            wxChar _T(char ch)

            const wxChar * _T(const wxChar ch)

            This macro is exactly the same as wxT and is defined in wxWidgets simply because it may be more intuitive for Windows programmers as the standard Win32 headers also define it (as well as yet another name for the same macro which is _TEXT()).

            Don't confuse this macro with _()!



            posted on 2008-12-24 14:24 Morya 閱讀(1051) 評論(1)  編輯 收藏 引用


            只有注冊用戶登錄后才能發(fā)表評論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


            導(dǎo)航

            <2008年12月>
            30123456
            78910111213
            14151617181920
            21222324252627
            28293031123
            45678910

            統(tǒng)計

            常用鏈接

            留言簿(1)

            隨筆檔案(21)

            文章檔案(1)

            最新評論

            評論排行榜

            99精品久久精品一区二区| 国产69精品久久久久观看软件| 无码任你躁久久久久久老妇App| 精品久久久久久久久免费影院| 久久精品免费全国观看国产| 久久九九兔免费精品6| 波多野结衣中文字幕久久| 国产精品成人久久久久久久| 亚洲国产精品成人久久蜜臀| 国产激情久久久久久熟女老人| 97超级碰碰碰久久久久| 中文字幕无码av激情不卡久久 | 久久亚洲精品无码aⅴ大香| 人妻无码αv中文字幕久久琪琪布 人妻无码久久一区二区三区免费 人妻无码中文久久久久专区 | 日韩久久无码免费毛片软件| 久久久久亚洲AV无码专区首JN| 一本久久久久久久| 精品久久久无码21p发布| 久久久91人妻无码精品蜜桃HD| 三上悠亚久久精品| 欧美激情精品久久久久久久| 久久精品免费一区二区三区| 亚洲综合熟女久久久30p| 久久www免费人成精品香蕉| 色狠狠久久AV五月综合| 久久综合九色综合网站| 久久午夜综合久久| 精品国产婷婷久久久| 国内精品久久国产大陆| 色综合久久久久久久久五月| 三级韩国一区久久二区综合| 久久国产美女免费观看精品| 久久精品国产亚洲AV麻豆网站| 国产亚洲精久久久久久无码77777| 精品人妻伦一二三区久久| 91精品国产91久久久久久| 精品久久久久久无码中文字幕一区| 伊人久久久AV老熟妇色| 久久婷婷五月综合色高清 | 精品久久人人爽天天玩人人妻 | 精品一久久香蕉国产线看播放|