am cf84f8ce: Switch from script to language codes.
* commit 'cf84f8ce0c65923dc9a66e386c17ab9de338accf': Switch from script to language codes.main
commit
920b3fd32a
|
@ -46,29 +46,30 @@ public class ScriptUtils {
|
||||||
public static final int SCRIPT_TELUGU = 16;
|
public static final int SCRIPT_TELUGU = 16;
|
||||||
public static final int SCRIPT_THAI = 17;
|
public static final int SCRIPT_THAI = 17;
|
||||||
|
|
||||||
private static final TreeMap<String, Integer> mIso15924toImeScriptCode;
|
private static final TreeMap<String, Integer> mLanguageCodeToScriptCode;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
mIso15924toImeScriptCode = new TreeMap<>();
|
mLanguageCodeToScriptCode = new TreeMap<>();
|
||||||
mIso15924toImeScriptCode.put("Arab", SCRIPT_ARABIC);
|
mLanguageCodeToScriptCode.put("", SCRIPT_LATIN); // default
|
||||||
mIso15924toImeScriptCode.put("Armn", SCRIPT_ARMENIAN);
|
mLanguageCodeToScriptCode.put("ar", SCRIPT_ARABIC);
|
||||||
mIso15924toImeScriptCode.put("Beng", SCRIPT_BENGALI);
|
mLanguageCodeToScriptCode.put("hy", SCRIPT_ARMENIAN);
|
||||||
mIso15924toImeScriptCode.put("Cyrl", SCRIPT_CYRILLIC);
|
mLanguageCodeToScriptCode.put("bn", SCRIPT_BENGALI);
|
||||||
mIso15924toImeScriptCode.put("Deva", SCRIPT_DEVANAGARI);
|
mLanguageCodeToScriptCode.put("bg", SCRIPT_CYRILLIC);
|
||||||
mIso15924toImeScriptCode.put("Geor", SCRIPT_GEORGIAN);
|
mLanguageCodeToScriptCode.put("sr", SCRIPT_CYRILLIC);
|
||||||
mIso15924toImeScriptCode.put("Grek", SCRIPT_GREEK);
|
mLanguageCodeToScriptCode.put("ru", SCRIPT_CYRILLIC);
|
||||||
mIso15924toImeScriptCode.put("Hebr", SCRIPT_HEBREW);
|
mLanguageCodeToScriptCode.put("ka", SCRIPT_GEORGIAN);
|
||||||
mIso15924toImeScriptCode.put("Knda", SCRIPT_KANNADA);
|
mLanguageCodeToScriptCode.put("el", SCRIPT_GREEK);
|
||||||
mIso15924toImeScriptCode.put("Khmr", SCRIPT_KHMER);
|
mLanguageCodeToScriptCode.put("he", SCRIPT_HEBREW);
|
||||||
mIso15924toImeScriptCode.put("Laoo", SCRIPT_LAO);
|
mLanguageCodeToScriptCode.put("km", SCRIPT_KHMER);
|
||||||
mIso15924toImeScriptCode.put("Latn", SCRIPT_LATIN);
|
mLanguageCodeToScriptCode.put("lo", SCRIPT_LAO);
|
||||||
mIso15924toImeScriptCode.put("Mlym", SCRIPT_MALAYALAM);
|
mLanguageCodeToScriptCode.put("ml", SCRIPT_MALAYALAM);
|
||||||
mIso15924toImeScriptCode.put("Mymr", SCRIPT_MYANMAR);
|
mLanguageCodeToScriptCode.put("my", SCRIPT_MYANMAR);
|
||||||
mIso15924toImeScriptCode.put("Sinh", SCRIPT_SINHALA);
|
mLanguageCodeToScriptCode.put("si", SCRIPT_SINHALA);
|
||||||
mIso15924toImeScriptCode.put("Taml", SCRIPT_TAMIL);
|
mLanguageCodeToScriptCode.put("ta", SCRIPT_TAMIL);
|
||||||
mIso15924toImeScriptCode.put("Telu", SCRIPT_TELUGU);
|
mLanguageCodeToScriptCode.put("te", SCRIPT_TELUGU);
|
||||||
mIso15924toImeScriptCode.put("Thai", SCRIPT_THAI);
|
mLanguageCodeToScriptCode.put("th", SCRIPT_THAI);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Returns whether the code point is a letter that makes sense for the specified
|
* Returns whether the code point is a letter that makes sense for the specified
|
||||||
* locale for this spell checker.
|
* locale for this spell checker.
|
||||||
|
@ -179,15 +180,16 @@ public class ScriptUtils {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param locale spell checker locale
|
* @param locale spell checker locale
|
||||||
* @return internal Latin IME script code that maps to an ISO 15924 script code
|
* @return internal Latin IME script code that maps to a language code
|
||||||
* {@see http://unicode.org/iso15924/iso15924-codes.html}
|
* {@see http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes}
|
||||||
*/
|
*/
|
||||||
public static int getScriptFromSpellCheckerLocale(final Locale locale) {
|
public static int getScriptFromSpellCheckerLocale(final Locale locale) {
|
||||||
String isoScriptCode = locale.getScript();
|
String language = locale.getLanguage();
|
||||||
Integer imeScriptCode = mIso15924toImeScriptCode.get(isoScriptCode);
|
Integer script = mLanguageCodeToScriptCode.get(language);
|
||||||
if (imeScriptCode == null) {
|
if (script == null) {
|
||||||
throw new RuntimeException("Unsupported ISO 15924 code: " + isoScriptCode);
|
// Default to Latin.
|
||||||
|
script = mLanguageCodeToScriptCode.get("");
|
||||||
}
|
}
|
||||||
return imeScriptCode;
|
return script;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue