summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Roozbeh Pournader <roozbeh@google.com> 2015-12-14 21:54:26 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2015-12-14 21:54:26 +0000
commit3cac67c0743d8d3b5ff0fe846ff32efaa088aeb6 (patch)
tree4fe31640f022fb6acc8d010d0fd84602a0fc731b
parent40aa9f1b989a7896fb683a5a7dd664aa3174012d (diff)
parenta1c0a82ba677d2aa6f5bb98d31588e0ab96c1107 (diff)
Merge "Load Portuguese and German hyphenation in Hyphenator"
-rw-r--r--core/java/android/text/Hyphenator.java36
1 files changed, 31 insertions, 5 deletions
diff --git a/core/java/android/text/Hyphenator.java b/core/java/android/text/Hyphenator.java
index 5d9d92910d1f..568b2671ad82 100644
--- a/core/java/android/text/Hyphenator.java
+++ b/core/java/android/text/Hyphenator.java
@@ -72,10 +72,20 @@ public class Hyphenator {
return result;
}
- // TODO: Convert this a proper locale-fallback system
+ // If there's a variant, fall back to language+variant only, if available
+ final String variant = locale.getVariant();
+ if (!variant.isEmpty()) {
+ final Locale languageAndVariantOnlyLocale =
+ new Locale(locale.getLanguage(), "", variant);
+ result = sMap.get(languageAndVariantOnlyLocale);
+ if (result != null) {
+ sMap.put(locale, result);
+ return result;
+ }
+ }
// Fall back to language-only, if available
- Locale languageOnlyLocale = new Locale(locale.getLanguage());
+ final Locale languageOnlyLocale = new Locale(locale.getLanguage());
result = sMap.get(languageOnlyLocale);
if (result != null) {
sMap.put(locale, result);
@@ -83,9 +93,9 @@ public class Hyphenator {
}
// Fall back to script-only, if available
- String script = locale.getScript();
+ final String script = locale.getScript();
if (!script.equals("")) {
- Locale scriptOnlyLocale = new Locale.Builder()
+ final Locale scriptOnlyLocale = new Locale.Builder()
.setLanguage("und")
.setScript(script)
.build();
@@ -142,6 +152,11 @@ public class Hyphenator {
{"en-UM", "en-US"}, // English (United States Minor Outlying Islands)
{"en-VI", "en-US"}, // English (Virgin Islands)
+ // For German, we're assuming the 1996 (and later) orthography by default.
+ {"de", "de-1996"},
+ // Liechtenstein uses the Swiss hyphenation rules for the 1901 orthography.
+ {"de-LI-1901", "de-CH-1901"},
+
// Norwegian is very probably Norwegian Bokmål.
{"no", "nb"},
@@ -166,7 +181,18 @@ public class Hyphenator {
sMap.put(null, null);
// TODO: replace this with a discovery-based method that looks into /system/usr/hyphen-data
- String[] availableLanguages = {"en-US", "es", "eu", "hu", "hy", "nb", "nn", "und-Ethi"};
+ String[] availableLanguages = {
+ "de-1901", "de-1996", "de-CH-1901",
+ "en-US",
+ "es",
+ "eu",
+ "hu",
+ "hy",
+ "nb",
+ "nn",
+ "pt",
+ "und-Ethi"
+ };
for (int i = 0; i < availableLanguages.length; i++) {
String languageTag = availableLanguages[i];
Hyphenator h = loadHyphenator(languageTag);