Freigeben über


Locale.LanguageRange.MapEquivalents Method

Definition

Generates a new customized Language Priority List using the given priorityList and map.

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

Parameters

priorityList
IList<Locale.LanguageRange>

user's Language Priority List

map
IDictionary<String,IList<String>>

a map containing information to customize language ranges

Returns

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

Attributes

Remarks

Generates a new customized Language Priority List using the given priorityList and map. If the given map is empty, this method returns a copy of the given priorityList.

In the map, a key represents a language range whereas a value is a list of equivalents of it. '*' cannot be used in the map. Each equivalent language range has the same weight value as its original language range.

An example of map:
<b>Key</b>                            <b>Value</b>
                 "zh" (Chinese)                 "zh",
                                                "zh-Hans"(Simplified Chinese)
                 "zh-HK" (Chinese, Hong Kong)   "zh-HK"
                 "zh-TW" (Chinese, Taiwan)      "zh-TW"

The customization is performed after modification using the IANA Language Subtag Registry.

For example, if a user's Language Priority List consists of five language ranges ("zh", "zh-CN", "en", "zh-TW", and "zh-HK"), the newly generated Language Priority List which is customized using the above map example will consists of "zh", "zh-Hans", "zh-CN", "zh-Hans-CN", "en", "zh-TW", and "zh-HK".

"zh-HK" and "zh-TW" aren't converted to "zh-Hans-HK" nor "zh-Hans-TW" even if they are included in the Language Priority List. In this example, mapping is used to clearly distinguish Simplified Chinese and Traditional Chinese.

If the "zh"-to-"zh" mapping isn't included in the map, a simple replacement will be performed and the customized list won't include "zh" and "zh-CN".

Java documentation for java.util.Locale.LanguageRange.mapEquivalents(java.util.List<java.util.Locale.LanguageRange>, 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