檢視原始碼 wxLocale (wx v2.4.3)

wxLocale 類別封裝了所有與語言相關的設定,並且是 C 語言環境概念的概括。

在 wxWidgets 中,此類別管理目前的語言環境。它還初始化並啟動 wxTranslations(在 wx 中未實作)物件,該物件管理訊息目錄。

如需支援的語言清單,請參閱 ?wxLanguage 列舉值。這些常數可用於在 init/3 中指定語言,並由 getSystemLanguage/0 返回。

請參閱

wxWidgets 文件:wxLocale

摘要

函式

呼叫 wxTranslations::AddCatalog(const wxString&)。

呼叫 wxTranslations::AddCatalog(const wxString&, wxLanguage) (在 wx 中未實作)。

呼叫 wxTranslations::AddCatalog(const wxString&, wxLanguage, const wxString&) (在 wx 中未實作)。

呼叫 wxFileTranslationsLoader::AddCatalogLookupPathPrefix() (在 wx 中未實作)。

銷毀物件

返回目前語言環境名稱的正規形式。

呼叫 wxTranslations::GetHeaderValue() (在 wx 中未實作)。

返回目前語言的 ?wxLanguage 常數。

返回指定語言的英文名稱,如果此語言未知,則返回空字串。

返回傳遞給建構子或 init/3 的語言環境名稱。

返回目前語言環境的短名稱 (如同傳遞給建構子或 init/3 函式)。

呼叫 wxGetTranslation(const wxString&, const wxString&)。

呼叫 wxGetTranslation(const wxString&, const wxString&, unsigned, const wxString&)。

返回傳遞給 setlocale() 的目前平台特定語言環境名稱。

嘗試偵測使用者的預設字型編碼。

嘗試偵測使用者預設字型編碼的名稱。

嘗試偵測使用者的預設語言環境設定。

等同於 init(This, [])

初始化 wxLocale 實例。

已過時

呼叫 wxTranslations::IsLoaded() (在 wx 中未實作)。

如果語言環境可以成功設定,則返回 true。

這是預設的建構子,它不會初始化物件:必須使用 init/3 來執行此操作。

等同於: new/2

有關參數說明,請參閱 init/3

類型

-type wxLocale() :: wx:wx_object().

函式

連結到此函式

addCatalog(This, Domain)

檢視原始碼
-spec addCatalog(This, Domain) -> boolean() when This :: wxLocale(), Domain :: unicode:chardata().

呼叫 wxTranslations::AddCatalog(const wxString&)。

連結到此函式

addCatalog(This, Domain, MsgIdLanguage)

檢視原始碼
-spec addCatalog(This, Domain, MsgIdLanguage) -> boolean()
                    when This :: wxLocale(), Domain :: unicode:chardata(), MsgIdLanguage :: wx:wx_enum().

呼叫 wxTranslations::AddCatalog(const wxString&, wxLanguage) (在 wx 中未實作)。

連結到此函式

addCatalog(This, Domain, MsgIdLanguage, MsgIdCharset)

檢視原始碼
-spec addCatalog(This, Domain, MsgIdLanguage, MsgIdCharset) -> boolean()
                    when
                        This :: wxLocale(),
                        Domain :: unicode:chardata(),
                        MsgIdLanguage :: wx:wx_enum(),
                        MsgIdCharset :: unicode:chardata().

呼叫 wxTranslations::AddCatalog(const wxString&, wxLanguage, const wxString&) (在 wx 中未實作)。

連結到此函式

addCatalogLookupPathPrefix(Prefix)

檢視原始碼
-spec addCatalogLookupPathPrefix(Prefix) -> ok when Prefix :: unicode:chardata().

呼叫 wxFileTranslationsLoader::AddCatalogLookupPathPrefix() (在 wx 中未實作)。

-spec destroy(This :: wxLocale()) -> ok.

銷毀物件

連結到此函式

getCanonicalName(This)

檢視原始碼
-spec getCanonicalName(This) -> unicode:charlist() when This :: wxLocale().

返回目前語言環境名稱的正規形式。

正規形式是在 UNIX 系統上使用的形式:它是 xx 或 xx_YY 格式的雙字母或五字母字串,其中 xx 是語言的 ISO 639 代碼,而 YY 是國家/地區的 ISO 3166 代碼。範例包括 "en"、"en_GB"、"en_US" 或 "fr_FR"。在查找訊息目錄時,內部會使用此形式。比較 getSysName/1

連結到此函式

getHeaderValue(This, Header)

檢視原始碼
-spec getHeaderValue(This, Header) -> unicode:charlist()
                        when This :: wxLocale(), Header :: unicode:chardata().

等同於 getHeaderValue(This, Header, [])

-spec getHeaderValue(This, Header, [Option]) -> unicode:charlist()
                        when
                            This :: wxLocale(),
                            Header :: unicode:chardata(),
                            Option :: {szDomain, unicode:chardata()}.

呼叫 wxTranslations::GetHeaderValue() (在 wx 中未實作)。

-spec getLanguage(This) -> integer() when This :: wxLocale().

返回目前語言的 ?wxLanguage 常數。

請注意,只有在使用採用 ?wxLanguage 引數的 init/3 形式時,才能呼叫此函式。

-spec getLanguageName(Lang) -> unicode:charlist() when Lang :: integer().

返回指定語言的英文名稱,如果此語言未知,則返回空字串。

有關 wxLANGUAGE_DEFAULT 的特殊含義的說明,請參閱 GetLanguageInfo() (在 wx 中未實作)。

-spec getLocale(This) -> unicode:charlist() when This :: wxLocale().

返回傳遞給建構子或 init/3 的語言環境名稱。

這是一個完整的、人類可讀的名稱,例如 "English" 或 "French"。

-spec getName(This) -> unicode:charlist() when This :: wxLocale().

返回目前語言環境的短名稱 (如同傳遞給建構子或 init/3 函式)。

連結到此函式

getString(This, OrigString)

檢視原始碼
-spec getString(This, OrigString) -> unicode:charlist()
                   when This :: wxLocale(), OrigString :: unicode:chardata().

等同於 getString(This, OrigString, [])

-spec getString(This, OrigString, [Option]) -> unicode:charlist()
                   when
                       This :: wxLocale(),
                       OrigString :: unicode:chardata(),
                       Option :: {szDomain, unicode:chardata()}.

呼叫 wxGetTranslation(const wxString&, const wxString&)。

連結到此函式

getString(This, OrigString, OrigString2, N)

檢視原始碼
-spec getString(This, OrigString, OrigString2, N) -> unicode:charlist()
                   when
                       This :: wxLocale(),
                       OrigString :: unicode:chardata(),
                       OrigString2 :: unicode:chardata(),
                       N :: integer().

等同於 getString(This, OrigString, OrigString2, N, [])

-spec getString(This, OrigString, OrigString2, N, [Option]) -> unicode:charlist()
                   when
                       This :: wxLocale(),
                       OrigString :: unicode:chardata(),
                       OrigString2 :: unicode:chardata(),
                       N :: integer(),
                       Option :: {szDomain, unicode:chardata()}.

呼叫 wxGetTranslation(const wxString&, const wxString&, unsigned, const wxString&)。

-spec getSysName(This) -> unicode:charlist() when This :: wxLocale().

返回傳遞給 setlocale() 的目前平台特定語言環境名稱。

比較 getCanonicalName/1

-spec getSystemEncoding() -> wx:wx_enum().

嘗試偵測使用者的預設字型編碼。

返回 ?wxFontEncoding() 值,如果無法確定,則返回 wxFONTENCODING_SYSTEM

連結到此函式

getSystemEncodingName()

檢視原始碼
-spec getSystemEncodingName() -> unicode:charlist().

嘗試偵測使用者預設字型編碼的名稱。

此字串對應用程式而言並非特別有用,因為其形式與平台相關,因此您可能應該改用 getSystemEncoding/0

返回使用者可讀的字串值,如果無法確定,則返回空字串。

-spec getSystemLanguage() -> integer().

嘗試偵測使用者的預設語言環境設定。

如果語言猜測演算法失敗,則返回 ?wxLanguage 值或 wxLANGUAGE_UNKNOWN

注意:此函式適用於 locales,並返回使用者的預設語言環境。這可能而且通常與他們偏好的 UI 語言相同,但這並非同一件事。使用 wxTranslation 來取得 language 資訊。

-spec init(This) -> boolean() when This :: wxLocale().

等同於 init(This, [])

-spec init(This, [Option]) -> boolean()
              when This :: wxLocale(), Option :: {language, integer()} | {flags, integer()}.

初始化 wxLocale 實例。

呼叫此函式會產生數個您應該理解的全域副作用:首先,會變更應用程式的語言環境 - 請注意,這會影響許多標準 C 語言程式庫函式,例如 printf() 或 strftime()。其次,此 wxLocale 物件會變成應用程式的新目前全域語言環境,因此所有後續對 ?wxGetTranslation() 的呼叫都會嘗試使用此語言環境的訊息目錄來翻譯訊息。

返回:成功時返回 true,如果無法設定指定的語言環境,則返回 false。

-spec init(This, Name, [Option]) -> boolean()
              when
                  This :: wxLocale(),
                  Name :: unicode:chardata(),
                  Option ::
                      {shortName, unicode:chardata()} |
                      {locale, unicode:chardata()} |
                      {bLoadDefault, boolean()}.

已過時

此形式已過時,除非您知道自己在做什麼,否則請使用其他形式。

連結到此函式

isLoaded(This, Domain)

檢視原始碼
-spec isLoaded(This, Domain) -> boolean() when This :: wxLocale(), Domain :: unicode:chardata().

呼叫 wxTranslations::IsLoaded() (在 wx 中未實作)。

-spec isOk(This) -> boolean() when This :: wxLocale().

如果語言環境可以成功設定,則返回 true。

-spec new() -> wxLocale().

這是預設的建構子,它不會初始化物件:必須使用 init/3 來執行此操作。

-spec new(Language) -> wxLocale() when Language :: integer();
         (Name) -> wxLocale() when Name :: unicode:chardata().

等同於: new/2

-spec new(Language, [Option]) -> wxLocale() when Language :: integer(), Option :: {flags, integer()};
         (Name, [Option]) -> wxLocale()
             when
                 Name :: unicode:chardata(),
                 Option ::
                     {shortName, unicode:chardata()} |
                     {locale, unicode:chardata()} |
                     {bLoadDefault, boolean()}.

有關參數說明,請參閱 init/3

呼叫此函式會產生數個您應該理解的全域副作用:首先,會變更應用程式的語言環境 - 請注意,這會影響許多標準 C 語言程式庫函式,例如 printf() 或 strftime()。其次,此 wxLocale 物件會變成應用程式的新目前全域語言環境,因此所有後續對 ?wxGetTranslation() 的呼叫都會嘗試使用此語言環境的訊息目錄來翻譯訊息。