com.android.ide.common.resources
Class LocaleManager

java.lang.Object
  extended by com.android.ide.common.resources.LocaleManager

public class LocaleManager
extends java.lang.Object

The LocaleManager provides access to locale information such as language names and language to region name mappings for the various locales.


Method Summary
static java.lang.String getDefaultLanguageRegion(java.lang.String languageCode)
          Like getLanguageRegion(String), but does not take user preferences and locations into consideration.
static java.lang.String getLanguageAlpha2(java.lang.String languageCode)
          Returns the corresponding ISO 639 alpha-2 code given an alpha-3 code
static java.lang.String getLanguageAlpha3(java.lang.String languageCode)
          Returns the corresponding ISO 639 alpha-3 code given an alpha-2 code
static java.util.List<java.lang.String> getLanguageCodes()
          Returns all the known language codes
static java.util.List<java.lang.String> getLanguageCodes(boolean include3)
          Returns all the known language codes
static java.lang.String getLanguageName(java.lang.String languageCode)
          Returns the name of the given language for a language code, in English.
static java.lang.String getLanguageRegion(java.lang.String languageCode)
          Returns the region code for the given language.
static java.lang.String getLanguageRegion(java.lang.String languageCode, ResourceRepository resources)
          Returns the region code for the given language.
static java.lang.String getRegionAlpha2(java.lang.String regionCode)
          Returns the corresponding ISO 3166 alpha-2 code given an alpha-3 code
static java.lang.String getRegionAlpha3(java.lang.String regionCode)
          Returns the corresponding ISO 3166 alpha-3 code given an alpha-2 code
static java.util.List<java.lang.String> getRegionCodes()
          Returns all the known region codes
static java.util.List<java.lang.String> getRegionCodes(boolean include3)
          Returns all the known region codes
static java.lang.String getRegionName(java.lang.String regionCode)
          Returns the name of the given region for a 2 letter region code, in English.
static java.util.List<java.lang.String> getRelevantRegions(java.lang.String languageCode)
          Returns the relevant regions for the given language, if known.
static java.lang.String getTimeZoneRegionAlpha2(java.util.TimeZone zone)
          Guess the 2-letter region code containing the given time zone
static java.lang.String getTimeZoneRegionAlpha3(java.util.TimeZone zone)
          Guess the 3-letter region code containing the given time zone
static boolean isValidLanguageCode(java.lang.String languageCode)
          Returns true if the given language code represents a valid/known 2 or 3 letter language code.
static boolean isValidRegionCode(java.lang.String regionCode)
          Returns true if the given region code represents a valid/known 2 or 3 letter region code.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getRegionName

@Nullable
public static java.lang.String getRegionName(@NonNull
                                                      java.lang.String regionCode)
Returns the name of the given region for a 2 letter region code, in English.

Parameters:
regionCode - the 2 letter region code (ISO 3166-1 alpha-2), or the 3 letter region ode (ISO 3166-2 alpha-3)
Returns:
the name of the given region for a region code, in English, or null if not known

getLanguageName

@Nullable
public static java.lang.String getLanguageName(@NonNull
                                                        java.lang.String languageCode)
Returns the name of the given language for a language code, in English.

Parameters:
languageCode - the 2 letter language code (ISO 639-1), or 3 letter language code (ISO 639-2)
Returns:
the name of the given language for a language code, in English, or null if not known

getLanguageCodes

@NonNull
public static java.util.List<java.lang.String> getLanguageCodes()
Returns all the known language codes

Returns:
all the known language codes

getLanguageCodes

@NonNull
public static java.util.List<java.lang.String> getLanguageCodes(boolean include3)
Returns all the known language codes

Parameters:
include3 - If true, include 3-letter language codes as well (for languages not available as 2-letter languages)
Returns:
all the known language codes

getRegionCodes

@NonNull
public static java.util.List<java.lang.String> getRegionCodes()
Returns all the known region codes

Returns:
all the known region codes

getRegionCodes

@NonNull
public static java.util.List<java.lang.String> getRegionCodes(boolean include3)
Returns all the known region codes

Parameters:
include3 - If true, include 3-letter region codes as well (for regions not available as 2-letter regions)
Returns:
all the known region codes

isValidLanguageCode

public static boolean isValidLanguageCode(@NonNull
                                          java.lang.String languageCode)
Returns true if the given language code represents a valid/known 2 or 3 letter language code. (By convention, language codes should be lower case.)

Parameters:
languageCode - the language code to look up
Returns:
true if this is a known language

isValidRegionCode

public static boolean isValidRegionCode(@NonNull
                                        java.lang.String regionCode)
Returns true if the given region code represents a valid/known 2 or 3 letter region code. (By convention, region codes should be upper case.)

Parameters:
regionCode - the region code to look up
Returns:
true if this is a known region

getLanguageRegion

@Nullable
public static java.lang.String getLanguageRegion(@NonNull
                                                          java.lang.String languageCode)
Returns the region code for the given language. Note that there can be many regions that speak a given language; this just picks one based on a set of heuristics.

Parameters:
languageCode - the language to look up
Returns:
the corresponding region code, if any

getDefaultLanguageRegion

@Nullable
public static java.lang.String getDefaultLanguageRegion(@NonNull
                                                                 java.lang.String languageCode)
Like getLanguageRegion(String), but does not take user preferences and locations into consideration.


getLanguageRegion

@Nullable
public static java.lang.String getLanguageRegion(@NonNull
                                                          java.lang.String languageCode,
                                                          @Nullable
                                                          ResourceRepository resources)
Returns the region code for the given language. Note that there can be many regions that speak a given language; this just picks one based on a set of heuristics.

Parameters:
languageCode - the language to look up
Returns:
the corresponding region code, if any

getRelevantRegions

@NonNull
public static java.util.List<java.lang.String> getRelevantRegions(@NonNull
                                                                          java.lang.String languageCode)
Returns the relevant regions for the given language, if known.


getLanguageAlpha2

@Nullable
public static java.lang.String getLanguageAlpha2(@NonNull
                                                          java.lang.String languageCode)
Returns the corresponding ISO 639 alpha-2 code given an alpha-3 code

Parameters:
languageCode - the ISO 639 alpha-3 code
Returns:
the corresponding ISO 639 alpha-2 code, if any

getLanguageAlpha3

@Nullable
public static java.lang.String getLanguageAlpha3(@NonNull
                                                          java.lang.String languageCode)
Returns the corresponding ISO 639 alpha-3 code given an alpha-2 code

Parameters:
languageCode - the ISO 639 alpha-2 code
Returns:
the corresponding ISO 639 alpha-3 code, if any

getRegionAlpha2

@Nullable
public static java.lang.String getRegionAlpha2(@NonNull
                                                        java.lang.String regionCode)
Returns the corresponding ISO 3166 alpha-2 code given an alpha-3 code

Parameters:
regionCode - the ISO 3166 alpha-3 code
Returns:
the corresponding ISO 3166 alpha-2 code, if any

getRegionAlpha3

@Nullable
public static java.lang.String getRegionAlpha3(@NonNull
                                                        java.lang.String regionCode)
Returns the corresponding ISO 3166 alpha-3 code given an alpha-2 code

Parameters:
regionCode - the ISO 3166 alpha-2 code
Returns:
the corresponding ISO 3166 alpha-3 code, if any

getTimeZoneRegionAlpha3

@Nullable
public static java.lang.String getTimeZoneRegionAlpha3(@NonNull
                                                                java.util.TimeZone zone)
Guess the 3-letter region code containing the given time zone

Parameters:
zone - The timezone to look up
Returns:
the corresponding 3 letter region code

getTimeZoneRegionAlpha2

@Nullable
public static java.lang.String getTimeZoneRegionAlpha2(@NonNull
                                                                java.util.TimeZone zone)
Guess the 2-letter region code containing the given time zone

Parameters:
zone - The timezone to look up
Returns:
the corresponding 2 letter region code