|
|||||||||||||||||||||||||||||||||||||||||||||||||
Note that the language and country fields are type UInt16 instead of LanguageType and CountryType. CompatibilityThe LmLocaleType is defined only if 4.0 New Feature Set is present. It supersedes the OmLocaleType that was introduced with Palm OS 3.5. LmLocaleType is bit-compatible with OmLocaleType.
NumberFormatType
The NumberFormatType enum specifies how numbers are formatted. You can pass a NumberFormatType value to LocGetNumberSeparators and receive the appropriate separator characters for thousands and decimals. typedef enum { nfCommaPeriod, nfPeriodComma, nfSpaceComma, nfApostrophePeriod, nfApostropheComma } NumberFormatType; Value Descriptions
Locale Manager Constants
Character Encoding Constants
The PalmLocale.h file defines several character encoding constants that are used as values of CharEncodingType variables. The character encoding constants generally follow the format: charEncodingName where Name is the name of the character encoding. The following table shows examples of the character encoding constants. For a complete list, see the PalmLocale.h file.
Country Constants
The PalmLocale.h file defines several country constants that are used as values of CountryType variables. The country type constants have the following format: cCountryName where CountryName is the name of the country. There is one constant for each country identified in the ISO 3166 standard, which currently defines 239 countries. The following table shows examples of the country type constants. For a complete list, see the PalmLocale.h file.
Language Constants
The PalmLocale.h file defines several language constants that are used as values of LanguageType variables. The language type constants have the following format: lLanguageName where LanguageName is the name of the language. There is one constant for each language specified in the ISO 639 standard, which currently defines 137 languages. The following table shows examples of the language type constants. For a complete list, see the PalmLocale.h file.
Locale Manager Size Constants
You can use the Locale Manager size constants to determine the size of strings to allocate for some of the locale settings. NOTE: The variables in the table below do not count the terminating null character. Therefore, you need to allocate a string of size kMaxCountryNameLen+1 to hold a country name, for example.
Locale Manager Functions
|
-> iLocaleIndex | Index of the locale whose settings you want to retrieve. |
-> iChoice | The setting you want to retrieve. This is a constant in the form lmChoiceSettingName. See Table 38.1 for a list of possible values. |
<- oValue | The value of the iChoice setting. The size of this buffer depends on the value of iChoice, as shown in Table 38.1. |
-> iValueSize | The size of the oValue buffer. |
Returns one of the following values:
errNone | Success. |
lmErrBadLocaleIndex | iLocaleIndex is out of range. |
lmErrSettingDataOverflow | The oValue buffer is too small to hold the setting's value. |
lmErrBadLocaleSettingChoice | The iChoice parameter contains an unknown or unsupported value. |
This function accesses the private locale system resource and returns the requested information in the oValue parameter. The size and type of the oValue parameter depend on which setting you want to retrieve. Table 38.1 lists and describes the possible settings and the type of data returned in oValue for each setting. For fixed-size values, make sure that oValue is no larger than the returned value.
This function returns the default settings for the locale. Users can override many of the locale settings using the Preferences application. Applications should always honor the user's preferences rather than the locale defaults. For this reason, it's recommended that if a corresponding system preference is available, you should check it instead (using PrefGetPreference). Use LmGetLocaleSetting only if you want to retrieve values that the user cannot override (such as the country name or currency symbol) or if you want to retrieve information about a locale other than the current locale.
Implemented only if 4.0 New Feature Set is present. To use this function in code intended to be run on earlier versions of Palm OS, link with the PalmOSGlue library and call LmGlueGetLocaleSetting. For more information, see Chapter 76, "PalmOSGlue Library."
LmGetNumLocales, LmLocaleToIndex
Return the number of known locales.
None. |
Returns the number of locales that the locale system resource defines.
Use this function to obtain the range of possible values that you can pass as an index to LmGetLocaleSetting. If LmGetNumLocales returns 3, then LmGetLocaleSetting accepts indexes in the range of 0 to 2.
This function returns only the number of locales for which the ROM has locale information. It does not return the number of locales that could possibly be defined. For example, the system resource currently contains no locale whose language is lHebrew and country is cIsrael, even though that is a valid locale.
Implemented only if 4.0 New Feature Set is present. To use this function in code intended to be run on earlier versions of Palm OS, link with the PalmOSGlue library and call LmGlueGetNumLocales. For more information, see Chapter 76, "PalmOSGlue Library."
Convert an LmLocaleType to an index.
Err LmLocaleToIndex (const LmLocaleType *iLocale, UInt16 *oLocaleIndex)
-> iLocale | The locale to convert. |
<- oLocaleIndex | The index of iLocale upon return. |
Returns errNone upon success or lmErrUnknownLocale if the locale could not be found.
You can use this function to obtain a valid index to pass to LmGetLocaleSetting. For example, you might use the Overlay Manager routine OmGetSystemLocale to return the locale used on the current system and then pass that locale to this function to obtain its index.
LmLocaleType locale; Char oValue[kMaxCurrencySymbolLen+1]; UInt16 index; OmGetSystemLocale(&locale); LmLocaleToIndex(&locale, &index); LmGetLocaleSetting(index, lmChoiceCurrencySymbol, oValue, sizeof(oValue));
The LmLocaleType that is passed in iLocale can use the constants lmAnyCountry or lmAnyLanguage as wildcards. For example, if the country is lmAnyCountry, LmLocaleToIndex returns the index of the first locale that matches the language.
Implemented only if 4.0 New Feature Set is present. To use this function in code intended to be run on earlier versions of Palm OS, link with the PalmOSGlue library and call LmGlueLocaleToIndex. For more information, see Chapter 76, "PalmOSGlue Library."
|