Compartir a través de


Locale.LanguageRange.Parse Method

Definition

Overloads

Parse(String)

Parses the given ranges to generate a Language Priority List.

Parse(String, IDictionary<String,IList<String>>)

Parses the given ranges to generate a Language Priority List, and then customizes the list using the given map.

Parse(String)

Parses the given ranges to generate a Language Priority List.

[Android.Runtime.Register("parse", "(Ljava/lang/String;)Ljava/util/List;", "", ApiSince=26)]
public static System.Collections.Generic.IList<Java.Util.Locale.LanguageRange> Parse (string ranges);
[<Android.Runtime.Register("parse", "(Ljava/lang/String;)Ljava/util/List;", "", ApiSince=26)>]
static member Parse : string -> System.Collections.Generic.IList<Java.Util.Locale.LanguageRange>

Parameters

ranges
String

a list of comma-separated language ranges or a list of language ranges in the form of the "Accept-Language" header defined in RFC 2616

Returns

a Language Priority List consisting of language ranges included in the given ranges and their equivalent language ranges if available. The list is modifiable.

Attributes

Remarks

Parses the given ranges to generate a Language Priority List.

This method performs a syntactic check for each language range in the given ranges but doesn't do validation using the IANA Language Subtag Registry.

The ranges to be given can take one of the following forms:

"Accept-Language: ja,en;q=0.4"  (weighted list with Accept-Language prefix)
              "ja,en;q=0.4"                   (weighted list)
              "ja,en"                         (prioritized list)

In a weighted list, each language range is given a weight value. The weight value is identical to the "quality value" in RFC 2616, and it expresses how much the user prefers the language. A weight value is specified after a corresponding language range followed by ";q=", and the default weight value is MAX_WEIGHT when it is omitted.

Unlike a weighted list, language ranges in a prioritized list are sorted in the descending order based on its priority. The first language range has the highest priority and meets the user's preference most.

In either case, language ranges are sorted in descending order in the Language Priority List based on priority or weight. If a language range appears in the given ranges more than once, only the first one is included on the Language Priority List.

The returned list consists of language ranges from the given ranges and their equivalents found in the IANA Language Subtag Registry. For example, if the given ranges is "Accept-Language: iw,en-us;q=0.7,en;q=0.3", the elements in the list to be returned are:

<b>Range</b>                                   <b>Weight</b>
               "iw" (older tag for Hebrew)             1.0
               "he" (new preferred code for Hebrew)    1.0
               "en-us" (English, United States)        0.7
               "en" (English)                          0.3

Two language ranges, "iw" and "he", have the same highest priority in the list. By adding "he" to the user's Language Priority List, locale-matching method can find Hebrew as a matching locale (or language tag) even if the application or system offers only "he" as a supported locale (or language tag).

Java documentation for java.util.Locale.LanguageRange.parse(java.lang.String).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

Parse(String, IDictionary<String,IList<String>>)

Parses the given ranges to generate a Language Priority List, and then customizes the list using the given map.

[Android.Runtime.Register("parse", "(Ljava/lang/String;Ljava/util/Map;)Ljava/util/List;", "", ApiSince=26)]
public static System.Collections.Generic.IList<Java.Util.Locale.LanguageRange> Parse (string ranges, System.Collections.Generic.IDictionary<string,System.Collections.Generic.IList<string>> map);
[<Android.Runtime.Register("parse", "(Ljava/lang/String;Ljava/util/Map;)Ljava/util/List;", "", ApiSince=26)>]
static member Parse : string * System.Collections.Generic.IDictionary<string, System.Collections.Generic.IList<string>> -> System.Collections.Generic.IList<Java.Util.Locale.LanguageRange>

Parameters

ranges
String

a list of comma-separated language ranges or a list of language ranges in the form of the "Accept-Language" header defined in RFC 2616

map
IDictionary<String,IList<String>>

a map containing information to customize language ranges

Returns

a Language Priority List with customization. The list is modifiable.

Attributes

Remarks

Parses the given ranges to generate a Language Priority List, and then customizes the list using the given map. This method is equivalent to mapEquivalents(parse(ranges), map).

Java documentation for java.util.Locale.LanguageRange.parse(java.lang.String, java.util.Map<java.lang.String, java.util.List<java.lang.String>>).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to