GetLanguageID
Gets a record with the language code and country code for the current system locale.
Declaration
Source position: translations.pas line 192
Function result
TLanguageID instance with the language identifier and country code for the current locale.
Description
GetLanguageID is a TLanguageID function which returns a record with language code (in ISO 639-1 or ISO 639-2) and country code (in ISO 3166) for the current system locale. The implementation is based on GetLanguageIDs procedure from the GetText unit, but is rewritten to have the following properties:
- Language and country codes are returned in ISO formats on Windows.
- A Unix locale identifier is properly parsed and language/country codes are properly extracted.
- Don't assume that language code is always two-letters (ISO 639-1), it can have a bigger length (e. g. three letters, like in ISO 639-2).
- Provides support for locale information on Darwin platforms. macOS does not set language environment variables for GUI applications which are not started from a terminal. This routine ensures that locale information is available for both console applications and GUI applications, independent of environment variables like LC_ALL / LC_MESSAGES / LANG, or Application bundle settings. The locale information uses ISO formats like `ru_RU`, `zh_CN`, or `it_IT`.
- Returns the locale information in a record type. This allows additional fields in a backwards-compatible manner. Currently it contains language ID, language code and country code.
GetLanguageID is used in the implementation of routines in the lcltranslator.pas unit, and can be called by other components and classes which use the localization feature.
Version info
Added in LazUtils version 3.0.
See also
TLanguageID |
|
Record type used to return language and country codes/identifiers for a locale. |
| Version 4.4 |
Generated 2025-11-08 |
Home |