W3C


3.4 Providing Locale Preferences

The optional i18n:preferences element information item MUST appear at most one time in the children property of the i18n:international element information item. If present, it MUST follow the i18n:tz element information item or (if i18n:tz is omitted) the i18n:locale element information item.

The i18n:preferences element information item represents a way to construct specific locale preferences and overrides. Support for the <i18n:preferences> element is OPTIONAL and specific behavior in relation to any particular preference is implementation dependent. Implementations of this specification are not required to recognize, support, or acknowledge the i18n:preferences element information item or any of its sub-elements. Services MUST NOT require a i18n:preferences element information item be sent in order to operate correctly.

[DC begins]

3.4.1 Providing Language Information

The optional i18n:language element information item MAY appear at most one time in the children property of the i18n:preferences element information item.

The i18n:language element information item represents the natural language of the web services interaction. Its value MUST be a valid [BCP 47] language tag.

An example of the usage of i18n:language is given below.

In this example, the i18n:language element information item is used to override the natural language to French (fr). The German locale (de-DE) is used for the rest of the locale sensitive service operations such as data formatting.

(01) <i18n:international>
(02) <i18n:locale>de-DE</i18n:locale>
(03) <i18n:preferences>
(04) <i18n:language>fr</i18n:language>
(05) </i18n:preferences>
(06) </i18n:international>


3.4.2 Providing Collation Information

The optional i18n:collation element information item MAY appear at most one time in the children property of the i18n:preferences element information item.

The i18n:collation element information item represents the collation used in the web services operation. Its value MUST be a valid [IANA] collation identifier.

An example of the usage of i18n:collation is given below.

In this example, the i18n:collation element information item is used to convey the usage of the "i;ascii-casemap" collation, which operates on US-ASCII letters in a case-insensitive manner.

(01) <i18n:international>
(02) <i18n:locale>en-US</i18n:locale>
(03) <i18n:preferences>
(04) <i18n:collation>i;ascii-casemap</i18n:collation>
(05) </i18n:preferences>
(06) </i18n:international>


3.4.3 Providing Date Time Format Information

The optional date time format information items MAY appear in the children property of the i18n:preferences element information item. They are indicated using the calendar elements of [LDML].

(01) <ldml:calendar type=" calendar type based on [LDML] ">
(02) <ldml:dateFormats>
(03) <ldml:dateFormatLength type=" date format length based on [LDML] ">
(04) <ldml:dateFormat>
(05) <ldml:pattern> date format pattern based on [LDML] </ldml:pattern>
(06) </ldml:dateFormat>
(07) </ldml:dateFormatLength>
(08) <ldml:dateFormats>
(09) <ldml:timeFormats>
(10) <ldml:timeFormatLength type=" time format length based on [LDML] ">
(11) <ldml:timeFormat>
(12) <ldml:pattern> time format pattern based on [LDML] </ldml:pattern>
(13) </ldml:timeFormat>
(14) </ldml:timeFormatLength>
(15) <ldml:timeFormats>
(16) <ldml:dateTimeFormats>
(17) <ldml:dateTimeFormatLength type=" date time format length based on [LDML] ">
(18) <ldml:dateTimeFormat>
(19) <ldml:pattern> date time format pattern based on [LDML] </ldml:pattern>
(20) </ldml:dateTimeFormat>
(21) </ldml:dateTimeFormatLength>
(22) <ldml:dateTimeFormats>
(23) </i18n:calendar>

The ldml:calender element information item represents specific date time format(s) used in the web services operation. The ldml:calender element and any child date time format element MAY appear multiple times if their combination of the type attributes are different from each other. All values under the ldml:calender element MUST conform to [LDML].

Gregorian calendar is the default calendar system. That is, the ldml:calender element MAY be omitted, in which case the elements ldml:dateFormatLength, ldml:timeFormatLength and ldml:dateTimeFormatLength MAY appear as an immediate child of the i18n:preferences element.

An example of the usage of date time format information is given below.

In this example, the ldml:pattern element represents a specific date format of medium length for the gregorian calendar.

(01) <i18n:international>
(02) <i18n:locale>en-US</i18n:locale>
(03) <i18n:preferences>
(04) <ldml:dateFormatLength type="medium">
(05) <ldml:dateFormat>
(06) <ldml:pattern>MMM dd, yyyy</ldml:pattern>
(07) </ldml:dateFormat>
(08) </ldml:dateFormatLength>
(09) </i18n:preferences>
(10) </i18n:international>

3.4.4 Providing Number Format Information

The optional number format information items MAY appear in the children property of the i18n:preferences element information item. They are indicated using the number elements of [LDML].

(01) <ldml:numbers>
(02) <ldml:decimalFormats>
(03) <ldml:decimalFormatLength type=" decimal format length based on [LDML] ">
(04) <ldml:decimalFormat>
(05) <ldml:pattern> decimal format pattern based on [LDML] </ldml:pattern>
(06) </ldml:decimalFormat>
(07) </ldml:decimalFormatLength>
(08) <ldml:decimalFormats>
(09) <ldml:scientificFormats>
(10) <ldml:scientificFormatLength type=" scientific format length based on [LDML] ">
(11) <ldml:scientificFormat>
(12) <ldml:pattern> scientific format pattern based on [LDML] </ldml:pattern>
(13) </ldml:scientificFormat>
(14) </ldml:scientificFormatLength>
(15) <ldml:scientificFormats>
(16) <ldml:percentFormats>
(17) <ldml:percentFormatLength type=" percent format length based on [LDML] ">
(18) <ldml:percentFormat>
(19) <ldml:pattern> percent format pattern based on [LDML] </ldml:pattern>
(20) </ldml:percentFormat>
(21) </ldml:percentFormatLength>
(22) <ldml:percentFormats>
(23) <ldml:currencyFormats>
(24) <ldml:currencyFormatLength type=" currency format length based on [LDML] ">
(25) <ldml:currencyFormat>
(26) <ldml:pattern> currency format pattern based on [LDML] </ldml:pattern>
(27) </ldml:currencyFormat>
(28) </ldml:currencyFormatLength>
(29) <ldml:currencyFormats>
(30) </ldml:numbers>

The ldml:numbers element information item represents specific number format(s) used in the web services operation.  All values under the ldml:numbers element MUST conform to [LDML].

An example of the usage of number format information is given below.

In this example, the ldml:pattern element represents a specific long decimal format.

(01) <i18n:international>
(02) <i18n:locale>en-US</i18n:locale>
(03) <i18n:preferences>
(04) <ldml:numbers>
(05) <ldml:decimalFormats>
(06) <ldml:decimalFormatLength type="long">
(07) <ldml:decimalFormat>
(08) <ldml:pattern>,##0.###</ldml:pattern>
(09) </ldml:decimalFormat>
(10) </ldml:decimalFormatLength>
(05) </ldml:decimalFormats>
(04) </ldml:numbers>
(11) </i18n:preferences>
(12) </i18n:international>


3.4.5 Providing Currency Information

The optional currency element information item MAY appear in the children property of the i18n:preferences element information item. They are indicated using the number elements of [LDML].

(01) <ldml:currency type=" currency type based on [LDML] " />

The currency element information item represents the currency used in the web services operation. Its value MUST be a valid [LDML] currency type.

An example of the usage of i18n:collation is given below.

In this example, the ldml:currency element information item is used to express the preferred currency (US dollar) on a request or the currency used on the service response.

(01) <i18n:international>
(02) <i18n:locale>en-US</i18n:locale>
(03) <i18n:preferences>
(04) <ldml:currency type="USD" />
(05) </i18n:preferences>
(06) </i18n:international>

3.4.6 Using The Extension Point

The i18n:preferences element information item may contain other items that are not defined in this specification.

[DC end]

An example of the usage of i18n:preferences is given below. It describes preferences using [LDML].

In this example, the i18n:preferences element information item used to convey the usage of a specific metric system.

(01) <i18n:preferences>
(02) <ldml:measurementSystem type="metric" />
(03) </i18n:preferences>

The LDML alias element information item is demonstrated below as another example of the content of the i18n:preferences element information item. alias allows the application to specify a base locale or collection of data from the Common Locale Data Repository [CLDR] to serve as a basis for other preferences. Thus it can be used to import a large number of settings that the remaining preferences tailor.

If the following i18n header is received and the specific preferences requested are supported, then the service should be expected to obey the locale request of U.S. English ("en-US"), but uses the German ("de_DE") collation specified ("phonebook" in this case).

(01) <i18n:international>
(02) <i18n:locale>en_US</i18n:locale>
(03) <i18n:preferences>
(04) <ldml:collation>
(05) <ldml:alias source="de_DE" type="phonebook"/>
(06) </ldml:collation>
(07) </i18n:preferences>
(08) </i18n:international>