Difference between revisions of "Internationalization/dotnet locale"

m (Checking for default locale)
(Retrieving locale information)
 
Line 39: Line 39:
 
| full_date_time_pattern || dddd, d. MMMM yyyy HH:mm:ss
 
| full_date_time_pattern || dddd, d. MMMM yyyy HH:mm:ss
 
|-
 
|-
| long_date_pattern || dddd, d. MMMM yyyy
+
| long_date_pattern || dddd, d. MMMM yyyydddd
 
|-
 
|-
 
| long_time_pattern || HH:mm:ss
 
| long_time_pattern || HH:mm:ss
Line 58: Line 58:
 
|}
 
|}
  
 +
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.
 +
 +
 +
<!--HERE A LIST OF OTHER "Format specifier"
 +
**f, %f: The fraction of a second in single-digit precision. The remaining digits are truncated. Specify "%f" if the format pattern is not combined with other format patterns.
 +
**ff: The fraction of a second in double-digit precision. The remaining digits are truncated.
 +
**fff: The fraction of a second in three-digit precision. The remaining digits are truncated.
 +
**ffff: The fraction of a second in four-digit precision. The remaining digits are truncated.
 +
**fffff: The fraction of a second in five-digit precision. The remaining digits are truncated.
 +
**ffffff: The fraction of a second in six-digit precision. The remaining digits are truncated.
 +
**fffffff: The fraction of a second in seven-digit precision. The remaining digits are truncated.
 +
**F, %F: Displays the most significant digit of the seconds fraction. Nothing is displayed if the digit is zero. Specify "%F" if the format pattern is not combined with other format patterns.
 +
**FF: Displays the two most significant digits of the seconds fraction. However, trailing zeros, or two zero digits, are not displayed.
 +
**FFF: Displays the three most significant digits of the seconds fraction. However, trailing zeros, or three zero digits, are not displayed.
 +
**FFFF: Displays the four most significant digits of the seconds fraction. However, trailing zeros, or four zero digits, are not displayed.
 +
**FFFFF: Displays the five most significant digits of the seconds fraction. However, trailing zeros, or five zero digits, are not displayed.
 +
**FFFFFF: Displays the six most significant digits of the seconds fraction. However, trailing zeros, or six zero digits, are not displayed.
 +
**FFFFFFF: Displays the seven most significant digits of the seconds fraction. However, trailing zeros, or seven zero digits, are not displayed.
 +
**gg: The period or era. This pattern is ignored if the date to be formatted does not have an associated period or era string.
 +
**h, %h: The hour in a 12-hour clock. Single-digit hours will not have a leading zero. Specify "%h" if the format pattern is not combined with other format patterns.
 +
*hh: The hour in a 12-hour clock. Single-digit hours will have a leading zero.
 +
*H, %H: The hour in a 24-hour clock. Single-digit hours will not have a leading zero. Specify "%H" if the format pattern is not combined with other format patterns.
 +
*K: Different values of the DateTime.Kind property, that is, Local, Utc, or Unspecified.
 +
*m, %m: The minute. Single-digit minutes will not have a leading zero. Specify "%m" if the format pattern is not combined with other format patterns.
 +
*M, %M: The numeric month. Single-digit months will not have a leading zero. Specify "%M" if the format pattern is not combined with other format patterns.
 +
*MM: The numeric month. Single-digit months will have a leading zero.
 +
*MMM: The abbreviated name of the month, as defined in AbbreviatedMonthNames.
 +
*MMMM: The full name of the month, as defined in MonthNames.
 +
*s, %s: The second. Single-digit seconds will not have a leading zero. Specify "%s" if the format pattern is not combined with other format patterns.
 +
*ss: the second. Single-digit seconds will have a leading zero.
 +
*, %t: The first character in the AM/PM designator defined in AMDesignator or PMDesignator, if any. Specify "%t" if the format pattern is not combined with other format patterns.
 +
*t:The AM/PM designator defined in AMDesignator or PMDesignator, if any.
 +
*y, %y: The year without the century. If the year without the century is less than 10, the year is displayed with no leading zero. Specify "%y" if the format pattern is not combined with other format patterns.
 +
*yy: The year without the century. If the year without the century is less than 10, the year is displayed with a leading zero.
 +
*yyy: The year in three digits. If the year is less than 100, the year is displayed with a leading zero.
 +
*yyyyy: The year in five digits. Will pad with leading zeroes to get five digits. Exception: the Japanese and Taiwan calendars always behave as if "yy" was selected.
 +
*yyyyyy: The year in six digits. Will pad with leading zeroes to get six digits. Exception: the Japanese and Taiwan calendars always behave as if "yy" was selected. The pattern can be continued with a longer string of "y"s padding with more leading zeroes.
 +
*z, %z: The time zone offset ("+" or "-" followed by the hour only). Single-digit hours will not have a leading zero. For example, Pacific Standard Time is "-8". Specify "%z" if the format pattern is not combined with other format patterns.
 +
*zz: The time zone offset ("+" or "-" followed by the hour only). Single-digit hours will have a leading zero. For example, Pacific Standard Time is "-08".
 +
*zzz: The full time zone offset ("+" or "-" followed by the hour and minutes). Single-digit hours and minutes will have leading zeros. For example, Pacific Standard Time is "-08:00".
 +
*% c: Where c is a format pattern if used alone. That is, to use format pattern "d", "f", "F", "h", "m", "s", "t", "y", "z", "H", or "M" by itself, specify "%d", "%f", "%F", "%h", "%m", "%s", "%t", "%y", "%z", "%H", or "%M". The "%" character can be omitted if the format pattern is combined with literal characters or other format patterns.
 +
*\ c Where c is any character. Displays the character literally. To display the backslash character, use "\\".
 +
-->
  
 
* there are also functions that return abbreviations of names of months and day:
 
* there are also functions that return abbreviations of names of months and day:

Latest revision as of 03:34, 7 September 2006


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