Internationalization/dotnet locale

Revision as of 03:16, 5 September 2006 by Etienner (Talk | contribs) (Checking for default locale)


Summary

There is a class named CULTURE_INFO in "mscorlib" in EiffelStudio, which provides information about a specific culture such as:

  • associated language
  • sublanguage
  • country/region
  • calendar
  • cultural conventions

Listing available locales

I didn't find a function that returns all the available locale informations, I think because under .NET, they are all avaiable.

Checking for default locale

a_culture_info : CULTURE_INFO
a_culture_info.current_culture.name : SYSTEM_STRING
    -- returns the name of the current culture info, (in the format described below).

Retrieving locale information

To obtain informations on a specific locale, it suffices to create an instance of CULTURE_INFO. There are basically two ways to do this:

  1. Create it with the culture identifier. This identifier maps every culture/language to an integer. It is not very usefull, because I did not find a logic behind the mapping function... You can find a table on here
  2. Create it with the name (STRING) of the culture. The culture names follow the RFC 1766 standard in the format "<languagecode2>-<country/regioncode2>", where <languagecode2> is a lowercase two-letter code derived from ISO 639-1 and <country/regioncode2> is an uppercase two-letter code derived from ISO 3166.

You can find a detailed description of RFC 1766

The CULTURE_INFO Class has some attibutes useful for the retrieving of the informations about Date, Time and Number formatting, they are:

  • date_time_format: DATE_TIME_FORMAT_INFO (see here)
Some information that is available in DATE_TIME_FORMAT_INFO
Information Result for locale "it-CH"
full_date_time_pattern dddd, d. MMMM yyyy HH:mm:ss
long_date_pattern dddd, d. MMMM yyyy
long_time_pattern HH:mm:ss
month_day_pattern d. MMMM
rfc1123_pattern ddd, dd MMM yyyy HH':'mm':'ss 'GMT'
pm_designator
short_date_pattern dd.MM.yyyy
short_time_pattern HH:mm
sortable_date_time_pattern yyyy'-'MM'-'dd'T'HH':'mm':'ss
time_separator


  • there are also functions that return abbreviations of names of months and day:
    • get_abbreviated_day_name (dayofweek: DAY_OF_WEEK) : SYSTEM_STRING
    • get_abbreviated_month_name (month: INTEGER) : SYSTEM_STRING


  • number_format: NUMBER_FORMAT_INFO (see here)


Some information that is available in NUMBER_FORMAT_INFO
Information Result for locale "it-CH"
currency_group_separator '
currency_symbol SFr.
currency_decimal_digits 2
negative_sign -
number_decimal_digits 2
number_decimal_separator .
number_group_separator '
positive_sign +
negative_sign -
negative_infinity_symbol -Infinito
per_mille_symbol ë
na_n_symbol Non un numero reale

Other information

References