Internationalization/dotnet locale


Contents

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 yyyydddd
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

where:

  • d, %d: The day of the month. Single-digit days will not have a leading zero. Specify "%d" if the format pattern is not combined with other format patterns.
  • dd: The day of the month. Single-digit days will have a leading zero.
  • ddd: The abbreviated name of the day of the week, as defined in AbbreviatedDayNames.
  • dddd: The full name of the day of the week, as defined in DayNames.
  • HH: The hour in a 24-hour clock. Single-digit hours will have a leading zero.
  • mm: The minute. Single-digit minutes will have a leading zero.
  • ss: the second. Single-digit seconds will have a leading zero.
  • yyyy: The year in four or five digits (depending on the calendar used), including the century. Will pad with leading zeroes to get four digits. Thai Buddhist and Korean calendars both have five digit years; users selecting the "yyyy" pattern will see all five digits without leading zeros for calendars that have five digits. Exception: the Japanese and Taiwan calendars always behave as if "yy" was selected.


  • 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