/*
*******************************************************************************
- * Copyright (C) 2009-2010, International Business Machines Corporation and *
+ * Copyright (C) 2009-2011, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
StringBuilder buf = new StringBuilder();
if (hasScript) {
// first element, don't need appender
- buf.append(scriptDisplayName(script));
+ buf.append(scriptDisplayNameInContext(script));
}
if (hasCountry) {
appender.append(regionDisplayName(country), buf);
@Override
public String scriptDisplayName(String script) {
+ String str = langData.get("Scripts%stand-alone", script);
+ if ( str.equals(script) ) {
+ return langData.get("Scripts", script);
+ } else {
+ return str;
+ }
+ }
+
+ @Override
+ public String scriptDisplayNameInContext(String script) {
return langData.get("Scripts", script);
}
/*
*******************************************************************************
- * Copyright (C) 2009-2010, International Business Machines Corporation and *
+ * Copyright (C) 2009-2011, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
* @stable ICU 4.4
*/
public abstract String scriptDisplayName(String script);
+
+ /**
+ * Returns the display name of the provided script code
+ * when used in the context of a full locale name.
+ * @param script the script code
+ * @return the display name of the provided script code
+ * @internal ICU 49
+ * @deprecated This API is ICU internal only.
+ */
+ public String scriptDisplayNameInContext(String script) {
+ return scriptDisplayName(script);
+ }
/**
* Returns the display name of the provided script code. See
return getDisplayScriptInternal(this, getDefault(Category.DISPLAY));
}
+ /**
+ * {@icu} Returns this locale's script localized for display in the default <code>DISPLAY</code> locale.
+ * @return the localized script name.
+ * @see Category#DISPLAY
+ * @internal ICU 49
+ * @deprecated This API is ICU internal only.
+ */
+ public String getDisplayScriptInContext() {
+ return getDisplayScriptInContextInternal(this, getDefault(Category.DISPLAY));
+ }
+
/**
* {@icu} Returns this locale's script localized for display in the provided locale.
* @param displayLocale the locale in which to display the name.
return getDisplayScriptInternal(this, displayLocale);
}
+ /**
+ * {@icu} Returns this locale's script localized for display in the provided locale.
+ * @param displayLocale the locale in which to display the name.
+ * @return the localized script name.
+ * @internal ICU 49
+ * @deprecated This API is ICU internal only.
+ */
+ public String getDisplayScriptInContext(ULocale displayLocale) {
+ return getDisplayScriptInContextInternal(this, displayLocale);
+ }
+
/**
* {@icu} Returns a locale's script localized for display in the provided locale.
* This is a cover for the ICU4C API.
public static String getDisplayScript(String localeID, String displayLocaleID) {
return getDisplayScriptInternal(new ULocale(localeID), new ULocale(displayLocaleID));
}
+ /**
+ * {@icu} Returns a locale's script localized for display in the provided locale.
+ * This is a cover for the ICU4C API.
+ * @param localeID the id of the locale whose script will be displayed
+ * @param displayLocaleID the id of the locale in which to display the name.
+ * @return the localized script name.
+ * @internal ICU 49
+ * @deprecated This API is ICU internal only.
+ */
+ public static String getDisplayScriptInContext(String localeID, String displayLocaleID) {
+ return getDisplayScriptInContextInternal(new ULocale(localeID), new ULocale(displayLocaleID));
+ }
/**
* {@icu} Returns a locale's script localized for display in the provided locale.
public static String getDisplayScript(String localeID, ULocale displayLocale) {
return getDisplayScriptInternal(new ULocale(localeID), displayLocale);
}
+ /**
+ * {@icu} Returns a locale's script localized for display in the provided locale.
+ * @param localeID the id of the locale whose script will be displayed.
+ * @param displayLocale the locale in which to display the name.
+ * @return the localized script name.
+ * @internal ICU 49
+ * @deprecated This API is ICU internal only.
+ */
+ public static String getDisplayScriptInContext(String localeID, ULocale displayLocale) {
+ return getDisplayScriptInContextInternal(new ULocale(localeID), displayLocale);
+ }
// displayLocaleID is canonical, localeID need not be since parsing will fix this.
private static String getDisplayScriptInternal(ULocale locale, ULocale displayLocale) {
.scriptDisplayName(locale.getScript());
}
+ private static String getDisplayScriptInContextInternal(ULocale locale, ULocale displayLocale) {
+ return LocaleDisplayNames.getInstance(displayLocale)
+ .scriptDisplayNameInContext(locale.getScript());
+ }
+
/**
* Returns this locale's country localized for display in the default <code>DISPLAY</code> locale.
* @return the localized country name.
", " + l.getDisplayName(ULocale.FRANCE));
String language = l.getDisplayLanguage();
- String script = l.getDisplayScript();
+ String script = l.getDisplayScriptInContext();
String country = l.getDisplayCountry();
String variant = l.getDisplayVariant();
name = l.getDisplayName(dl);
language = l.getDisplayLanguage(dl);
- script = l.getDisplayScript(dl);
+ script = l.getDisplayScriptInContext(dl);
country = l.getDisplayCountry(dl);
variant = l.getDisplayVariant(dl);
logln("Testing "+ testLocale+".....");
name = ULocale.getDisplayName(localeID, testLocale);
language = ULocale.getDisplayLanguage(localeID, testLocale);
- script = ULocale.getDisplayScript(localeID, testLocale);
+ script = ULocale.getDisplayScriptInContext(localeID, testLocale);
country = ULocale.getDisplayCountry(localeID, testLocale);
variant = ULocale.getDisplayVariant(localeID, testLocale);
logln("Testing "+ testLocale+".....");
name = ULocale.getDisplayName(localeID, loc);
language = ULocale.getDisplayLanguage(localeID, loc);
- script = ULocale.getDisplayScript(localeID, loc);
+ script = ULocale.getDisplayScriptInContext(localeID, loc);
country = ULocale.getDisplayCountry(localeID, loc);
variant = ULocale.getDisplayVariant(localeID, loc);