}
if (resultName == null) {
- resultName = localeIdName(lang);
+ resultName = localeIdName(lang)
+ .replace(formatOpenParen, formatReplaceOpenParen)
+ .replace(formatCloseParen, formatReplaceCloseParen);
}
StringBuilder buf = new StringBuilder();
if (hasScript) {
// first element, don't need appendWithSep
- buf.append(scriptDisplayNameInContext(script));
+ buf.append(scriptDisplayNameInContext(script)
+ .replace(formatOpenParen, formatReplaceOpenParen)
+ .replace(formatCloseParen, formatReplaceCloseParen));
}
if (hasCountry) {
- String regionDisplayName = regionDisplayName(country);
- regionDisplayName = regionDisplayName
+ appendWithSep(regionDisplayName(country)
.replace(formatOpenParen, formatReplaceOpenParen)
- .replace(formatCloseParen, formatReplaceCloseParen);
- appendWithSep(regionDisplayName, buf);
+ .replace(formatCloseParen, formatReplaceCloseParen), buf);
}
if (hasVariant) {
- appendWithSep(variantDisplayName(variant), buf);
+ appendWithSep(variantDisplayName(variant)
+ .replace(formatOpenParen, formatReplaceOpenParen)
+ .replace(formatCloseParen, formatReplaceCloseParen), buf);
}
Iterator<String> keys = locale.getKeywords();
while (keys.hasNext()) {
String key = keys.next();
String value = locale.getKeywordValue(key);
- String keyDisplayName = keyDisplayName(key);
- String valueDisplayName = keyValueDisplayName(key, value);
+ String keyDisplayName = keyDisplayName(key)
+ .replace(formatOpenParen, formatReplaceOpenParen)
+ .replace(formatCloseParen, formatReplaceCloseParen);
+ String valueDisplayName = keyValueDisplayName(key, value)
+ .replace(formatOpenParen, formatReplaceOpenParen)
+ .replace(formatCloseParen, formatReplaceCloseParen);
if (!valueDisplayName.equals(value)) {
appendWithSep(valueDisplayName, buf);
} else if (!key.equals(keyDisplayName)) {
}
private boolean checkName(String name, String language, String script, String country, String variant, ULocale dl) {
- if (language.length() > 0 && name.indexOf(language) == -1) {
- errln("loc: " + dl + " name '" + name + "' does not contain language '" + language + "'");
+ if (!checkInclusion(dl, name, language, "language")) {
return false;
}
- if (script.length() > 0 && name.indexOf(script) == -1) {
- errln("loc: " + dl + " name '" + name + "' does not contain script '" + script + "'");
+ if (!checkInclusion(dl, name, script, "script")) {
return false;
}
- if (country.length() > 0 && name.indexOf(country) == -1) {
- String country2 = country.replace('(', '[').replace(')',']').replace('(', '[').replace(')',']');
+ if (!checkInclusion(dl, name, country, "country")) {
+ return false;
+ }
+ if (!checkInclusion(dl, name, variant, "variant")) {
+ return false;
+ }
+ return true;
+ }
+
+ private boolean checkInclusion(ULocale dl, String name, String substring, String substringName) {
+ if (substring.length() > 0 && name.indexOf(substring) == -1) {
+ String country2 = substring.replace('(', '[').replace(')',']').replace('(', '[').replace(')',']');
if (name.indexOf(country2) == -1) {
- errln("loc: " + dl + " name '" + name + "' does not contain country '" + country + "'");
+ errln("loc: " + dl + " name '" + name + "' does not contain " +
+ substringName +
+ " '" + substring + "'");
return false;
-// } else {
-// System.out.println("loc: " + dl + " name '" + name + "' does not contain country '" + country + "'");
}
}
- if (variant.length() > 0 && name.indexOf(variant) == -1) {
- errln("loc: " + dl + " name '" + name + "' does not contain variant '" + variant + "'");
- return false;
- }
return true;
}
script = ULocale.getDisplayScriptInContext(localeID, testLocale);
country = ULocale.getDisplayCountry(localeID, testLocale);
variant = ULocale.getDisplayVariant(localeID, testLocale);
-
if (!checkName(name, language, script, country, variant, new ULocale(testLocale))) {
break;
}