Difference between revisions of "Internationalization/locale"
(→Windows) |
LinkUpdater (Talk | contribs) (→References and useful links) |
||
(19 intermediate revisions by 3 users not shown) | |||
Line 4: | Line 4: | ||
== Format of locale on OS's == | == Format of locale on OS's == | ||
− | * windows | + | * windows: hexadecimal code consisting of a language code (lower 10 bits) and culture code (upper bits), aka Locale Identifier (LCID). Note: the LCID is the same for different variants of language like Norwegian (Bokmal) and Norwegian (Nynorsk) (they use the same locale settings) |
+ | |||
* linux, unix: defined as [language[_territory][.codeset][@modifier]] | * linux, unix: defined as [language[_territory][.codeset][@modifier]] | ||
Line 45: | Line 46: | ||
The LCID for "Language for non-Unicode programs" (aka system locale) can be found in the windows registry.<br> | The LCID for "Language for non-Unicode programs" (aka system locale) can be found in the windows registry.<br> | ||
The LCID of "standards and formats" (aka user locale) doesn't seem to be in the registry nor in the environment variables of windows. | The LCID of "standards and formats" (aka user locale) doesn't seem to be in the registry nor in the environment variables of windows. | ||
+ | There are some macros defined in windows.h that help getting these values. | ||
== How to access to locale == | == How to access to locale == | ||
=== Linux === | === Linux === | ||
+ | The function "get" that fetches the language environment variable (LANG) can be found in class EXECUTION_ENVIRONMENT | ||
+ | |||
+ | SHARED_EXEC_ENVIRONMENT: located [https://eiffelsoftware.origo.ethz.ch/svn/es/branches/soft-arch/Src/Eiffel/eiffel/shared/shared_exec_environment.e here] | ||
=== Windows === | === Windows === | ||
In Eiffel there exist a "locale_id" in class WEL_COMPARE_ITEM_STRUCT that uses the macro MAKELCID to get the locale identifier (aka LCID) from the language id. | In Eiffel there exist a "locale_id" in class WEL_COMPARE_ITEM_STRUCT that uses the macro MAKELCID to get the locale identifier (aka LCID) from the language id. | ||
− | |||
− | |||
Two solutions:<br> | Two solutions:<br> | ||
− | * | + | * Get the language id |
* Use the locale id (convenient if SortID is needed) | * Use the locale id (convenient if SortID is needed) | ||
+ | in both cases the solution can be found the macros of windows.h | ||
− | Notes: | + | Notes:<br> |
Locale id is formed by SortID and LanguageID.<br> | Locale id is formed by SortID and LanguageID.<br> | ||
− | SortID contains info on the language encoding (?) like japanese unicode order, japanese XJIS order, chinese unicode order, chinese BIG5 order,... | + | SortID contains info on the language encoding (?) like japanese unicode order, japanese XJIS order, chinese unicode order, chinese BIG5 order,...<br> |
− | + | ||
Macros for windows are contained in "windows.h". | Macros for windows are contained in "windows.h". | ||
− | ''' | + | '''Needed macro (the one that gets the user LCID): GetUserDefaultLCID()''' |
+ | |||
+ | |||
+ | The code looks like this: | ||
+ | <code>[eiffel,N] | ||
+ | language_id: NATURAL_32 is | ||
+ | external | ||
+ | "C inline use <windows.h>" | ||
+ | alias | ||
+ | "return GetUserDefaultLCID();" | ||
+ | end | ||
+ | </code> | ||
− | + | == OS detection == | |
− | + | Queries for OS detection cam be found in class PLATFORM | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
== References and useful links == | == References and useful links == | ||
− | * [http://www | + | * [http://www.unicode.org/cldr/apps/survey CLDR Survey Tool] Contains info about what a locale can refer to (e.g. language codes, time format, ...) |
− | * [http://en.wikipedia.org/wiki/Date_and_time_notation_by_country | + | * [http://www.unicode.org/cldr/ Common Locale Data Repository] main page |
+ | * [http://en.wikipedia.org/wiki/Date_and_time_notation_by_country Date and time notations] | ||
* [http://en.wikipedia.org/wiki/Locale Locale on wikipedia] | * [http://en.wikipedia.org/wiki/Locale Locale on wikipedia] |
Latest revision as of 23:12, 2 November 2008
In computing, locale is a set of parameters that defines the user's language, country and any special variant preferences that the user wants to see in their user interface.
Contents
Format of locale on OS's
- windows: hexadecimal code consisting of a language code (lower 10 bits) and culture code (upper bits), aka Locale Identifier (LCID). Note: the LCID is the same for different variants of language like Norwegian (Bokmal) and Norwegian (Nynorsk) (they use the same locale settings)
- linux, unix: defined as [language[_territory][.codeset][@modifier]]
Where to find locale
Linux
the environment variable is LANG
here is a list for more specific variables:
Locale category | Application |
---|---|
LC_COLLATE | Collation of strings (sort order.) |
LC_CTYPE | Classification and conversion of characters. |
LC_MESSAGES | Translations of yes and no. |
LC_MONETARY | Format of monetary values. |
LC_NUMERIC | Format of non-monetary numeric values. |
LC_TIME | Date and time formats. |
LC_ALL | Sets all of the above (overrides all of them.) |
LANG | Sets all the categories, but can be overridden by the individual locale categories. |
Windows
The LCID for "Language for non-Unicode programs" (aka system locale) can be found in the windows registry.
The LCID of "standards and formats" (aka user locale) doesn't seem to be in the registry nor in the environment variables of windows.
There are some macros defined in windows.h that help getting these values.
How to access to locale
Linux
The function "get" that fetches the language environment variable (LANG) can be found in class EXECUTION_ENVIRONMENT
SHARED_EXEC_ENVIRONMENT: located here
Windows
In Eiffel there exist a "locale_id" in class WEL_COMPARE_ITEM_STRUCT that uses the macro MAKELCID to get the locale identifier (aka LCID) from the language id.
Two solutions:
- Get the language id
- Use the locale id (convenient if SortID is needed)
in both cases the solution can be found the macros of windows.h
Notes:
Locale id is formed by SortID and LanguageID.
SortID contains info on the language encoding (?) like japanese unicode order, japanese XJIS order, chinese unicode order, chinese BIG5 order,...
Macros for windows are contained in "windows.h".
Needed macro (the one that gets the user LCID): GetUserDefaultLCID()
The code looks like this:
language_id: NATURAL_32 is external "C inline use <windows.h>" alias "return GetUserDefaultLCID();" end
OS detection
Queries for OS detection cam be found in class PLATFORM
References and useful links
- CLDR Survey Tool Contains info about what a locale can refer to (e.g. language codes, time format, ...)
- Common Locale Data Repository main page
- Date and time notations
- Locale on wikipedia