Merge "Use locale to look up KeyboardTextsTable"

main
Tadashi G. Takaoka 2014-04-08 10:18:17 +00:00 committed by Android (Google) Code Review
commit 8afe218954
7 changed files with 273 additions and 262 deletions

View File

@ -41,8 +41,7 @@ public final class KeyboardTextsSet {
private HashMap<String, String> mResourceNameToTextsMap = CollectionUtils.newHashMap(); private HashMap<String, String> mResourceNameToTextsMap = CollectionUtils.newHashMap();
public void setLocale(final Locale locale, final Context context) { public void setLocale(final Locale locale, final Context context) {
final String language = locale.getLanguage(); mTextsTable = KeyboardTextsTable.getTextsTable(locale);
mTextsTable = KeyboardTextsTable.getTextsTable(language);
final Resources res = context.getResources(); final Resources res = context.getResources();
final int referenceId = context.getApplicationInfo().labelRes; final int referenceId = context.getApplicationInfo().labelRes;
final String resourcePackageName = res.getResourcePackageName(referenceId); final String resourcePackageName = res.getResourcePackageName(referenceId);

View File

@ -19,6 +19,7 @@ package com.android.inputmethod.keyboard.internal;
import com.android.inputmethod.latin.utils.CollectionUtils; import com.android.inputmethod.latin.utils.CollectionUtils;
import java.util.HashMap; import java.util.HashMap;
import java.util.Locale;
/** /**
* !!!!! DO NOT EDIT THIS FILE !!!!! * !!!!! DO NOT EDIT THIS FILE !!!!!
@ -44,19 +45,19 @@ import java.util.HashMap;
public final class KeyboardTextsTable { public final class KeyboardTextsTable {
// Name to index map. // Name to index map.
private static final HashMap<String, Integer> sNameToIndexesMap = CollectionUtils.newHashMap(); private static final HashMap<String, Integer> sNameToIndexesMap = CollectionUtils.newHashMap();
// Language to texts table map. // Locale to texts table map.
private static final HashMap<String, String[]> sLanguageToTextsTableMap = private static final HashMap<String, String[]> sLocaleToTextsTableMap =
CollectionUtils.newHashMap(); CollectionUtils.newHashMap();
// TODO: Remove this variable after debugging. // TODO: Remove this variable after debugging.
// Texts table to language maps. // Texts table to locale maps.
private static final HashMap<String[], String> sTextsTableToLanguageMap = private static final HashMap<String[], String> sTextsTableToLocaleMap =
CollectionUtils.newHashMap(); CollectionUtils.newHashMap();
public static String getText(final String name, final String[] textsTable) { public static String getText(final String name, final String[] textsTable) {
final Integer indexObj = sNameToIndexesMap.get(name); final Integer indexObj = sNameToIndexesMap.get(name);
if (indexObj == null) { if (indexObj == null) {
throw new RuntimeException("Unknown text name=" + name + " language=" throw new RuntimeException("Unknown text name=" + name + " locale="
+ sTextsTableToLanguageMap.get(textsTable)); + sTextsTableToLocaleMap.get(textsTable));
} }
final int index = indexObj; final int index = indexObj;
final String text = (index < textsTable.length) ? textsTable[index] : null; final String text = (index < textsTable.length) ? textsTable[index] : null;
@ -64,17 +65,24 @@ public final class KeyboardTextsTable {
return text; return text;
} }
// Sanity check. // Sanity check.
if (index >= 0 && index < LANGUAGE_DEFAULT.length) { if (index >= 0 && index < TEXTS_DEFAULT.length) {
return LANGUAGE_DEFAULT[index]; return TEXTS_DEFAULT[index];
} }
// Throw exception for debugging purpose. // Throw exception for debugging purpose.
throw new RuntimeException("Illegal index=" + index + " for name=" + name throw new RuntimeException("Illegal index=" + index + " for name=" + name
+ " language=" + sTextsTableToLanguageMap.get(textsTable)); + " locale=" + sTextsTableToLocaleMap.get(textsTable));
} }
public static String[] getTextsTable(final String language) { public static String[] getTextsTable(final Locale locale) {
final String[] textsTable = sLanguageToTextsTableMap.get(language); final String localeKey = locale.toString();
return textsTable != null ? textsTable : LANGUAGE_DEFAULT; if (sLocaleToTextsTableMap.containsKey(localeKey)) {
return sLocaleToTextsTableMap.get(localeKey);
}
final String languageKey = locale.getLanguage();
if (sLocaleToTextsTableMap.containsKey(languageKey)) {
return sLocaleToTextsTableMap.get(languageKey);
}
return TEXTS_DEFAULT;
} }
private static final String[] NAMES = { private static final String[] NAMES = {
@ -252,7 +260,7 @@ public final class KeyboardTextsTable {
private static final String EMPTY = ""; private static final String EMPTY = "";
/* Default texts */ /* Default texts */
private static final String[] LANGUAGE_DEFAULT = { private static final String[] TEXTS_DEFAULT = {
/* morekeys_a ~ */ /* morekeys_a ~ */
EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY,
/* ~ morekeys_c */ /* ~ morekeys_c */
@ -457,8 +465,8 @@ public final class KeyboardTextsTable {
/* keyspec_emoji_key */ "!icon/emoji_key|!code/key_emoji", /* keyspec_emoji_key */ "!icon/emoji_key|!code/key_emoji",
}; };
/* Language af: Afrikaans */ /* Locale af: Afrikaans */
private static final String[] LANGUAGE_af = { private static final String[] TEXTS_af = {
// This is the same as Dutch except more keys of y and demoting vowels with diaeresis. // This is the same as Dutch except more keys of y and demoting vowels with diaeresis.
// U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE
// U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX // U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX
@ -513,8 +521,8 @@ public final class KeyboardTextsTable {
/* morekeys_y */ "\u00FD,\u0133", /* morekeys_y */ "\u00FD,\u0133",
}; };
/* Language ar: Arabic */ /* Locale ar: Arabic */
private static final String[] LANGUAGE_ar = { private static final String[] TEXTS_ar = {
/* morekeys_a ~ */ /* morekeys_a ~ */
null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,
/* ~ single_quotes */ /* ~ single_quotes */
@ -640,8 +648,8 @@ public final class KeyboardTextsTable {
/* morekeys_symbols_percent */ "\\%,\u2030", /* morekeys_symbols_percent */ "\\%,\u2030",
}; };
/* Language az_AZ: Azerbaijani (Azerbaijan) */ /* Locale az_AZ: Azerbaijani (Azerbaijan) */
private static final String[] LANGUAGE_az_AZ = { private static final String[] TEXTS_az_AZ = {
// U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX // U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX
/* morekeys_a */ "\u00E2", /* morekeys_a */ "\u00E2",
// U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS // U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS
@ -688,8 +696,8 @@ public final class KeyboardTextsTable {
/* morekeys_g */ "\u011F", /* morekeys_g */ "\u011F",
}; };
/* Language be_BY: Belarusian (Belarus) */ /* Locale be_BY: Belarusian (Belarus) */
private static final String[] LANGUAGE_be_BY = { private static final String[] TEXTS_be_BY = {
/* morekeys_a ~ */ /* morekeys_a ~ */
null, null, null, null, null, null, null, null, null, null, null, null,
/* ~ morekeys_c */ /* ~ morekeys_c */
@ -721,8 +729,8 @@ public final class KeyboardTextsTable {
/* morekeys_cyrillic_soft_sign */ "\u044A", /* morekeys_cyrillic_soft_sign */ "\u044A",
}; };
/* Language bg: Bulgarian */ /* Locale bg: Bulgarian */
private static final String[] LANGUAGE_bg = { private static final String[] TEXTS_bg = {
/* morekeys_a ~ */ /* morekeys_a ~ */
null, null, null, null, null, null, null, null, null, null, null, null,
/* ~ morekeys_c */ /* ~ morekeys_c */
@ -737,8 +745,8 @@ public final class KeyboardTextsTable {
/* keylabel_to_alpha */ "\u0410\u0411\u0412", /* keylabel_to_alpha */ "\u0410\u0411\u0412",
}; };
/* Language ca: Catalan */ /* Locale ca: Catalan */
private static final String[] LANGUAGE_ca = { private static final String[] TEXTS_ca = {
// U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE
// U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE
// U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS
@ -816,8 +824,8 @@ public final class KeyboardTextsTable {
/* morekeys_tablet_punctuation */ "!autoColumnOrder!8,\\,,',\u00B7,#,),(,/,;,@,:,-,\",+,\\%,&", /* morekeys_tablet_punctuation */ "!autoColumnOrder!8,\\,,',\u00B7,#,),(,/,;,@,:,-,\",+,\\%,&",
}; };
/* Language cs: Czech */ /* Locale cs: Czech */
private static final String[] LANGUAGE_cs = { private static final String[] TEXTS_cs = {
// U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE
// U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE
// U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX // U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX
@ -894,8 +902,8 @@ public final class KeyboardTextsTable {
/* morekeys_r */ "\u0159", /* morekeys_r */ "\u0159",
}; };
/* Language da: Danish */ /* Locale da: Danish */
private static final String[] LANGUAGE_da = { private static final String[] TEXTS_da = {
// U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE
// U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS
// U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE
@ -963,8 +971,8 @@ public final class KeyboardTextsTable {
/* morekeys_nordic_row2_11 */ "\u00F6", /* morekeys_nordic_row2_11 */ "\u00F6",
}; };
/* Language de: German */ /* Locale de: German */
private static final String[] LANGUAGE_de = { private static final String[] TEXTS_de = {
// U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS
// U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX // U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX
// U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE
@ -1033,8 +1041,8 @@ public final class KeyboardTextsTable {
/* morekeys_swiss_row2_11 */ "\u00E0", /* morekeys_swiss_row2_11 */ "\u00E0",
}; };
/* Language el: Greek */ /* Locale el: Greek */
private static final String[] LANGUAGE_el = { private static final String[] TEXTS_el = {
/* morekeys_a ~ */ /* morekeys_a ~ */
null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,
/* ~ single_quotes */ /* ~ single_quotes */
@ -1045,8 +1053,8 @@ public final class KeyboardTextsTable {
/* keylabel_to_alpha */ "\u0391\u0392\u0393", /* keylabel_to_alpha */ "\u0391\u0392\u0393",
}; };
/* Language en: English */ /* Locale en: English */
private static final String[] LANGUAGE_en = { private static final String[] TEXTS_en = {
// U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE
// U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE
// U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX // U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX
@ -1094,8 +1102,8 @@ public final class KeyboardTextsTable {
/* morekeys_s */ "\u00DF", /* morekeys_s */ "\u00DF",
}; };
/* Language eo: Esperanto */ /* Locale eo: Esperanto */
private static final String[] LANGUAGE_eo = { private static final String[] TEXTS_eo = {
// U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE
// U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE
// U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX // U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX
@ -1243,8 +1251,8 @@ public final class KeyboardTextsTable {
/* keyspec_x */ "\u0109", /* keyspec_x */ "\u0109",
}; };
/* Language es: Spanish */ /* Locale es: Spanish */
private static final String[] LANGUAGE_es = { private static final String[] TEXTS_es = {
// U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE
// U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE
// U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS
@ -1306,8 +1314,8 @@ public final class KeyboardTextsTable {
/* morekeys_punctuation */ "!autoColumnOrder!9,\\,,?,!,#,),(,/,;,\u00A1,',@,:,-,\",+,\\%,&,\u00BF", /* morekeys_punctuation */ "!autoColumnOrder!9,\\,,?,!,#,),(,/,;,\u00A1,',@,:,-,\",+,\\%,&,\u00BF",
}; };
/* Language et_EE: Estonian (Estonia) */ /* Locale et_EE: Estonian (Estonia) */
private static final String[] LANGUAGE_et_EE = { private static final String[] TEXTS_et_EE = {
// U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS
// U+0101: "ā" LATIN SMALL LETTER A WITH MACRON // U+0101: "ā" LATIN SMALL LETTER A WITH MACRON
// U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE
@ -1409,8 +1417,8 @@ public final class KeyboardTextsTable {
/* morekeys_nordic_row2_10 */ "\u00F5", /* morekeys_nordic_row2_10 */ "\u00F5",
}; };
/* Language eu_ES: Basque (Spain) */ /* Locale eu_ES: Basque (Spain) */
private static final String[] LANGUAGE_eu_ES = { private static final String[] TEXTS_eu_ES = {
// U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE
// U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE
// U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS
@ -1463,8 +1471,8 @@ public final class KeyboardTextsTable {
/* morekeys_n */ "\u00F1,\u0144", /* morekeys_n */ "\u00F1,\u0144",
}; };
/* Language fa: Persian */ /* Locale fa: Persian */
private static final String[] LANGUAGE_fa = { private static final String[] TEXTS_fa = {
/* morekeys_a ~ */ /* morekeys_a ~ */
null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,
/* ~ single_quotes */ /* ~ single_quotes */
@ -1601,8 +1609,8 @@ public final class KeyboardTextsTable {
/* morekeys_greater_than */ "!fixedColumnOrder!3,!text/keyspec_right_single_angle_quote,!text/keyspec_greater_than_equal,!text/keyspec_greater_than", /* morekeys_greater_than */ "!fixedColumnOrder!3,!text/keyspec_right_single_angle_quote,!text/keyspec_greater_than_equal,!text/keyspec_greater_than",
}; };
/* Language fi: Finnish */ /* Locale fi: Finnish */
private static final String[] LANGUAGE_fi = { private static final String[] TEXTS_fi = {
// U+00E6: "æ" LATIN SMALL LETTER AE // U+00E6: "æ" LATIN SMALL LETTER AE
// U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE
// U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE
@ -1651,8 +1659,8 @@ public final class KeyboardTextsTable {
/* morekeys_nordic_row2_11 */ "\u00E6", /* morekeys_nordic_row2_11 */ "\u00E6",
}; };
/* Language fr: French */ /* Locale fr: French */
private static final String[] LANGUAGE_fr = { private static final String[] TEXTS_fr = {
// U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE
// U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX // U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX
// U+00E6: "æ" LATIN SMALL LETTER AE // U+00E6: "æ" LATIN SMALL LETTER AE
@ -1724,8 +1732,8 @@ public final class KeyboardTextsTable {
/* morekeys_swiss_row2_11 */ "\u00E4", /* morekeys_swiss_row2_11 */ "\u00E4",
}; };
/* Language gl_ES: Gallegan (Spain) */ /* Locale gl_ES: Gallegan (Spain) */
private static final String[] LANGUAGE_gl_ES = { private static final String[] TEXTS_gl_ES = {
// U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE
// U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE
// U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS
@ -1778,8 +1786,8 @@ public final class KeyboardTextsTable {
/* morekeys_n */ "\u00F1,\u0144", /* morekeys_n */ "\u00F1,\u0144",
}; };
/* Language hi: Hindi */ /* Locale hi: Hindi */
private static final String[] LANGUAGE_hi = { private static final String[] TEXTS_hi = {
/* morekeys_a ~ */ /* morekeys_a ~ */
null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,
/* ~ single_quotes */ /* ~ single_quotes */
@ -1830,8 +1838,8 @@ public final class KeyboardTextsTable {
/* additional_morekeys_symbols_0 */ "0", /* additional_morekeys_symbols_0 */ "0",
}; };
/* Language hr: Croatian */ /* Locale hr: Croatian */
private static final String[] LANGUAGE_hr = { private static final String[] TEXTS_hr = {
/* morekeys_a ~ */ /* morekeys_a ~ */
null, null, null, null, null, null, null, null, null, null,
/* ~ morekeys_i */ /* ~ morekeys_i */
@ -1863,8 +1871,8 @@ public final class KeyboardTextsTable {
/* double_angle_quotes */ "!text/double_raqm_laqm", /* double_angle_quotes */ "!text/double_raqm_laqm",
}; };
/* Language hu: Hungarian */ /* Locale hu: Hungarian */
private static final String[] LANGUAGE_hu = { private static final String[] TEXTS_hu = {
// U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE
// U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE
// U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX // U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX
@ -1917,8 +1925,8 @@ public final class KeyboardTextsTable {
/* double_angle_quotes */ "!text/double_raqm_laqm", /* double_angle_quotes */ "!text/double_raqm_laqm",
}; };
/* Language hy_AM: Armenian (Armenia) */ /* Locale hy_AM: Armenian (Armenia) */
private static final String[] LANGUAGE_hy_AM = { private static final String[] TEXTS_hy_AM = {
/* morekeys_a ~ */ /* morekeys_a ~ */
null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,
/* ~ single_quotes */ /* ~ single_quotes */
@ -1970,8 +1978,8 @@ public final class KeyboardTextsTable {
/* morekeys_exclamation */ "\u055C,\u00A1", /* morekeys_exclamation */ "\u055C,\u00A1",
}; };
/* Language is: Icelandic */ /* Locale is: Icelandic */
private static final String[] LANGUAGE_is = { private static final String[] TEXTS_is = {
// U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE
// U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS
// U+00E6: "æ" LATIN SMALL LETTER AE // U+00E6: "æ" LATIN SMALL LETTER AE
@ -2027,8 +2035,8 @@ public final class KeyboardTextsTable {
/* morekeys_t */ "\u00FE", /* morekeys_t */ "\u00FE",
}; };
/* Language it: Italian */ /* Locale it: Italian */
private static final String[] LANGUAGE_it = { private static final String[] TEXTS_it = {
// U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE
// U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE
// U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX // U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX
@ -2072,8 +2080,8 @@ public final class KeyboardTextsTable {
/* morekeys_i */ "\u00EC,\u00ED,\u00EE,\u00EF,\u012F,\u012B", /* morekeys_i */ "\u00EC,\u00ED,\u00EE,\u00EF,\u012F,\u012B",
}; };
/* Language iw: Hebrew */ /* Locale iw: Hebrew */
private static final String[] LANGUAGE_iw = { private static final String[] TEXTS_iw = {
/* morekeys_a ~ */ /* morekeys_a ~ */
null, null, null, null, null, null, null, null, null, null, null, null,
/* ~ morekeys_c */ /* ~ morekeys_c */
@ -2130,8 +2138,8 @@ public final class KeyboardTextsTable {
/* morekeys_plus */ "\u00B1,\uFB29", /* morekeys_plus */ "\u00B1,\uFB29",
}; };
/* Language ka_GE: Georgian (Georgia) */ /* Locale ka_GE: Georgian (Georgia) */
private static final String[] LANGUAGE_ka_GE = { private static final String[] TEXTS_ka_GE = {
/* morekeys_a ~ */ /* morekeys_a ~ */
null, null, null, null, null, null, null, null, null, null, null, null,
/* ~ morekeys_c */ /* ~ morekeys_c */
@ -2145,8 +2153,8 @@ public final class KeyboardTextsTable {
/* keylabel_to_alpha */ "\u10D0\u10D1\u10D2", /* keylabel_to_alpha */ "\u10D0\u10D1\u10D2",
}; };
/* Language kk: Kazakh */ /* Locale kk: Kazakh */
private static final String[] LANGUAGE_kk = { private static final String[] TEXTS_kk = {
/* morekeys_a ~ */ /* morekeys_a ~ */
null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,
/* ~ single_quotes */ /* ~ single_quotes */
@ -2202,8 +2210,8 @@ public final class KeyboardTextsTable {
/* morekeys_cyrillic_a */ "\u04D9", /* morekeys_cyrillic_a */ "\u04D9",
}; };
/* Language km_KH: Khmer (Cambodia) */ /* Locale km_KH: Khmer (Cambodia) */
private static final String[] LANGUAGE_km_KH = { private static final String[] TEXTS_km_KH = {
/* morekeys_a ~ */ /* morekeys_a ~ */
null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,
/* ~ single_quotes */ /* ~ single_quotes */
@ -2226,8 +2234,8 @@ public final class KeyboardTextsTable {
/* morekeys_currency_dollar */ "\u17DB,\u00A2,\u00A3,\u20AC,\u00A5,\u20B1", /* morekeys_currency_dollar */ "\u17DB,\u00A2,\u00A3,\u20AC,\u00A5,\u20B1",
}; };
/* Language ky: Kirghiz */ /* Locale ky: Kirghiz */
private static final String[] LANGUAGE_ky = { private static final String[] TEXTS_ky = {
/* morekeys_a ~ */ /* morekeys_a ~ */
null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,
/* ~ single_quotes */ /* ~ single_quotes */
@ -2268,8 +2276,8 @@ public final class KeyboardTextsTable {
/* morekeys_cyrillic_o */ "\u04E9", /* morekeys_cyrillic_o */ "\u04E9",
}; };
/* Language lo_LA: Lao (Laos) */ /* Locale lo_LA: Lao (Laos) */
private static final String[] LANGUAGE_lo_LA = { private static final String[] TEXTS_lo_LA = {
/* morekeys_a ~ */ /* morekeys_a ~ */
null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,
/* ~ single_quotes */ /* ~ single_quotes */
@ -2285,8 +2293,8 @@ public final class KeyboardTextsTable {
/* keyspec_currency */ "\u20AD", /* keyspec_currency */ "\u20AD",
}; };
/* Language lt: Lithuanian */ /* Locale lt: Lithuanian */
private static final String[] LANGUAGE_lt = { private static final String[] TEXTS_lt = {
// U+0105: "ą" LATIN SMALL LETTER A WITH OGONEK // U+0105: "ą" LATIN SMALL LETTER A WITH OGONEK
// U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS
// U+0101: "ā" LATIN SMALL LETTER A WITH MACRON // U+0101: "ā" LATIN SMALL LETTER A WITH MACRON
@ -2380,8 +2388,8 @@ public final class KeyboardTextsTable {
/* morekeys_k */ "\u0137", /* morekeys_k */ "\u0137",
}; };
/* Language lv: Latvian */ /* Locale lv: Latvian */
private static final String[] LANGUAGE_lv = { private static final String[] TEXTS_lv = {
// U+0101: "ā" LATIN SMALL LETTER A WITH MACRON // U+0101: "ā" LATIN SMALL LETTER A WITH MACRON
// U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE
// U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE
@ -2474,8 +2482,8 @@ public final class KeyboardTextsTable {
/* morekeys_k */ "\u0137", /* morekeys_k */ "\u0137",
}; };
/* Language mk: Macedonian */ /* Locale mk: Macedonian */
private static final String[] LANGUAGE_mk = { private static final String[] TEXTS_mk = {
/* morekeys_a ~ */ /* morekeys_a ~ */
null, null, null, null, null, null, null, null, null, null, null, null,
/* ~ morekeys_c */ /* ~ morekeys_c */
@ -2510,8 +2518,8 @@ public final class KeyboardTextsTable {
/* keyspec_south_slavic_row3_8 */ "\u0453", /* keyspec_south_slavic_row3_8 */ "\u0453",
}; };
/* Language mn_MN: Mongolian (Mongolia) */ /* Locale mn_MN: Mongolian (Mongolia) */
private static final String[] LANGUAGE_mn_MN = { private static final String[] TEXTS_mn_MN = {
/* morekeys_a ~ */ /* morekeys_a ~ */
null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,
/* ~ single_quotes */ /* ~ single_quotes */
@ -2527,8 +2535,8 @@ public final class KeyboardTextsTable {
/* keyspec_currency */ "\u20AE", /* keyspec_currency */ "\u20AE",
}; };
/* Language my_MM: Burmese (Myanmar) */ /* Locale my_MM: Burmese (Myanmar) */
private static final String[] LANGUAGE_my_MM = { private static final String[] TEXTS_my_MM = {
/* morekeys_a ~ */ /* morekeys_a ~ */
null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,
/* ~ single_quotes */ /* ~ single_quotes */
@ -2539,8 +2547,8 @@ public final class KeyboardTextsTable {
/* keylabel_to_alpha */ "\u1000\u1001\u1002", /* keylabel_to_alpha */ "\u1000\u1001\u1002",
}; };
/* Language nb: Norwegian Bokmål */ /* Locale nb: Norwegian Bokmål */
private static final String[] LANGUAGE_nb = { private static final String[] TEXTS_nb = {
// U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE
// U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS
// U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE
@ -2593,8 +2601,8 @@ public final class KeyboardTextsTable {
/* morekeys_nordic_row2_11 */ "\u00E4", /* morekeys_nordic_row2_11 */ "\u00E4",
}; };
/* Language ne_NP: Nepali (Nepal) */ /* Locale ne_NP: Nepali (Nepal) */
private static final String[] LANGUAGE_ne_NP = { private static final String[] TEXTS_ne_NP = {
/* morekeys_a ~ */ /* morekeys_a ~ */
null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,
/* ~ single_quotes */ /* ~ single_quotes */
@ -2645,8 +2653,8 @@ public final class KeyboardTextsTable {
/* additional_morekeys_symbols_0 */ "0", /* additional_morekeys_symbols_0 */ "0",
}; };
/* Language nl: Dutch */ /* Locale nl: Dutch */
private static final String[] LANGUAGE_nl = { private static final String[] TEXTS_nl = {
// U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE
// U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS
// U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX // U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX
@ -2699,8 +2707,8 @@ public final class KeyboardTextsTable {
/* morekeys_y */ "\u0133", /* morekeys_y */ "\u0133",
}; };
/* Language pl: Polish */ /* Locale pl: Polish */
private static final String[] LANGUAGE_pl = { private static final String[] TEXTS_pl = {
// U+0105: "ą" LATIN SMALL LETTER A WITH OGONEK // U+0105: "ą" LATIN SMALL LETTER A WITH OGONEK
// U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE
// U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE
@ -2755,8 +2763,8 @@ public final class KeyboardTextsTable {
/* morekeys_l */ "\u0142", /* morekeys_l */ "\u0142",
}; };
/* Language pt: Portuguese */ /* Locale pt: Portuguese */
private static final String[] LANGUAGE_pt = { private static final String[] TEXTS_pt = {
// U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE
// U+00E3: "ã" LATIN SMALL LETTER A WITH TILDE // U+00E3: "ã" LATIN SMALL LETTER A WITH TILDE
// U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE
@ -2803,8 +2811,8 @@ public final class KeyboardTextsTable {
/* morekeys_c */ "\u00E7,\u010D,\u0107", /* morekeys_c */ "\u00E7,\u010D,\u0107",
}; };
/* Language rm: Raeto-Romance */ /* Locale rm: Raeto-Romance */
private static final String[] LANGUAGE_rm = { private static final String[] TEXTS_rm = {
/* morekeys_a */ null, /* morekeys_a */ null,
// U+00F2: "ò" LATIN SMALL LETTER O WITH GRAVE // U+00F2: "ò" LATIN SMALL LETTER O WITH GRAVE
// U+00F3: "ó" LATIN SMALL LETTER O WITH ACUTE // U+00F3: "ó" LATIN SMALL LETTER O WITH ACUTE
@ -2816,8 +2824,8 @@ public final class KeyboardTextsTable {
/* morekeys_o */ "\u00F2,\u00F3,\u00F6,\u00F4,\u00F5,\u0153,\u00F8", /* morekeys_o */ "\u00F2,\u00F3,\u00F6,\u00F4,\u00F5,\u0153,\u00F8",
}; };
/* Language ro: Romanian */ /* Locale ro: Romanian */
private static final String[] LANGUAGE_ro = { private static final String[] TEXTS_ro = {
// U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX // U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX
// U+00E3: "ã" LATIN SMALL LETTER A WITH TILDE // U+00E3: "ã" LATIN SMALL LETTER A WITH TILDE
// U+0103: "ă" LATIN SMALL LETTER A WITH BREVE // U+0103: "ă" LATIN SMALL LETTER A WITH BREVE
@ -2855,8 +2863,8 @@ public final class KeyboardTextsTable {
/* morekeys_t */ "\u021B", /* morekeys_t */ "\u021B",
}; };
/* Language ru: Russian */ /* Locale ru: Russian */
private static final String[] LANGUAGE_ru = { private static final String[] TEXTS_ru = {
/* morekeys_a ~ */ /* morekeys_a ~ */
null, null, null, null, null, null, null, null, null, null, null, null,
/* ~ morekeys_c */ /* ~ morekeys_c */
@ -2888,8 +2896,8 @@ public final class KeyboardTextsTable {
/* morekeys_cyrillic_soft_sign */ "\u044A", /* morekeys_cyrillic_soft_sign */ "\u044A",
}; };
/* Language sk: Slovak */ /* Locale sk: Slovak */
private static final String[] LANGUAGE_sk = { private static final String[] TEXTS_sk = {
// U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE
// U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS
// U+0101: "ā" LATIN SMALL LETTER A WITH MACRON // U+0101: "ā" LATIN SMALL LETTER A WITH MACRON
@ -2983,8 +2991,8 @@ public final class KeyboardTextsTable {
/* morekeys_k */ "\u0137", /* morekeys_k */ "\u0137",
}; };
/* Language sl: Slovenian */ /* Locale sl: Slovenian */
private static final String[] LANGUAGE_sl = { private static final String[] TEXTS_sl = {
/* morekeys_a ~ */ /* morekeys_a ~ */
null, null, null, null, null, null, null, null, null, null,
/* ~ morekeys_i */ /* ~ morekeys_i */
@ -3009,8 +3017,8 @@ public final class KeyboardTextsTable {
/* double_angle_quotes */ "!text/double_raqm_laqm", /* double_angle_quotes */ "!text/double_raqm_laqm",
}; };
/* Language sr: Serbian */ /* Locale sr: Serbian */
private static final String[] LANGUAGE_sr = { private static final String[] TEXTS_sr = {
/* morekeys_a ~ */ /* morekeys_a ~ */
null, null, null, null, null, null, null, null, null, null, null, null,
/* ~ morekeys_c */ /* ~ morekeys_c */
@ -3069,8 +3077,8 @@ public final class KeyboardTextsTable {
/* keyspec_south_slavic_row3_8 */ "\u0452", /* keyspec_south_slavic_row3_8 */ "\u0452",
}; };
/* Language sv: Swedish */ /* Locale sv: Swedish */
private static final String[] LANGUAGE_sv = { private static final String[] TEXTS_sv = {
// U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE
// U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE
// U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX // U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX
@ -3155,8 +3163,8 @@ public final class KeyboardTextsTable {
/* morekeys_nordic_row2_11 */ "\u00E6", /* morekeys_nordic_row2_11 */ "\u00E6",
}; };
/* Language sw: Swahili */ /* Locale sw: Swahili */
private static final String[] LANGUAGE_sw = { private static final String[] TEXTS_sw = {
// This is the same as English except morekeys_g. // This is the same as English except morekeys_g.
// U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE
// U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE
@ -3209,8 +3217,8 @@ public final class KeyboardTextsTable {
/* morekeys_g */ "g\'", /* morekeys_g */ "g\'",
}; };
/* Language th: Thai */ /* Locale th: Thai */
private static final String[] LANGUAGE_th = { private static final String[] TEXTS_th = {
/* morekeys_a ~ */ /* morekeys_a ~ */
null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,
/* ~ single_quotes */ /* ~ single_quotes */
@ -3226,8 +3234,8 @@ public final class KeyboardTextsTable {
/* keyspec_currency */ "\u0E3F", /* keyspec_currency */ "\u0E3F",
}; };
/* Language tl: Tagalog */ /* Locale tl: Tagalog */
private static final String[] LANGUAGE_tl = { private static final String[] TEXTS_tl = {
// U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE
// U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE
// U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS
@ -3280,8 +3288,8 @@ public final class KeyboardTextsTable {
/* morekeys_n */ "\u00F1,\u0144", /* morekeys_n */ "\u00F1,\u0144",
}; };
/* Language tr: Turkish */ /* Locale tr: Turkish */
private static final String[] LANGUAGE_tr = { private static final String[] TEXTS_tr = {
// U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX // U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX
/* morekeys_a */ "\u00E2", /* morekeys_a */ "\u00E2",
// U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS // U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS
@ -3327,8 +3335,8 @@ public final class KeyboardTextsTable {
/* morekeys_g */ "\u011F", /* morekeys_g */ "\u011F",
}; };
/* Language uk: Ukrainian */ /* Locale uk: Ukrainian */
private static final String[] LANGUAGE_uk = { private static final String[] TEXTS_uk = {
/* morekeys_a ~ */ /* morekeys_a ~ */
null, null, null, null, null, null, null, null, null, null, null, null,
/* ~ morekeys_c */ /* ~ morekeys_c */
@ -3371,8 +3379,8 @@ public final class KeyboardTextsTable {
/* morekeys_cyrillic_ghe */ "\u0491", /* morekeys_cyrillic_ghe */ "\u0491",
}; };
/* Language vi: Vietnamese */ /* Locale vi: Vietnamese */
private static final String[] LANGUAGE_vi = { private static final String[] TEXTS_vi = {
// U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE
// U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE
// U+1EA3: "ả" LATIN SMALL LETTER A WITH HOOK ABOVE // U+1EA3: "ả" LATIN SMALL LETTER A WITH HOOK ABOVE
@ -3457,8 +3465,8 @@ public final class KeyboardTextsTable {
/* keyspec_currency */ "\u20AB", /* keyspec_currency */ "\u20AB",
}; };
/* Language zu: Zulu */ /* Locale zu: Zulu */
private static final String[] LANGUAGE_zu = { private static final String[] TEXTS_zu = {
// This is the same as English // This is the same as English
// U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE
// U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE
@ -3507,8 +3515,8 @@ public final class KeyboardTextsTable {
/* morekeys_s */ "\u00DF", /* morekeys_s */ "\u00DF",
}; };
/* Language zz: Alphabet */ /* Locale zz: Alphabet */
private static final String[] LANGUAGE_zz = { private static final String[] TEXTS_zz = {
// U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE
// U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE
// U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX // U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX
@ -3646,67 +3654,65 @@ public final class KeyboardTextsTable {
/* morekeys_j */ "\u0135", /* morekeys_j */ "\u0135",
}; };
// TODO: Use the language + "_" + region representation for the locale string key. private static final Object[] LOCALES_AND_TEXTS = {
// Currently we are dropping the region from the key.
private static final Object[] LANGUAGES_AND_TEXTS = {
// "locale", TEXT_ARRAY, /* numberOfNonNullText/lengthOf_TEXT_ARRAY localeName */ // "locale", TEXT_ARRAY, /* numberOfNonNullText/lengthOf_TEXT_ARRAY localeName */
"DEFAULT", LANGUAGE_DEFAULT, /* 168/168 default */ "DEFAULT", TEXTS_DEFAULT, /* 168/168 default */
"af", LANGUAGE_af, /* 7/ 12 Afrikaans */ "af" , TEXTS_af, /* 7/ 12 Afrikaans */
"ar", LANGUAGE_ar, /* 55/107 Arabic */ "ar" , TEXTS_ar, /* 55/107 Arabic */
"az", LANGUAGE_az_AZ, /* 8/ 17 Azerbaijani (Azerbaijan) */ "az_AZ" , TEXTS_az_AZ, /* 8/ 17 Azerbaijani (Azerbaijan) */
"be", LANGUAGE_be_BY, /* 9/ 32 Belarusian (Belarus) */ "be_BY" , TEXTS_be_BY, /* 9/ 32 Belarusian (Belarus) */
"bg", LANGUAGE_bg, /* 2/ 10 Bulgarian */ "bg" , TEXTS_bg, /* 2/ 10 Bulgarian */
"ca", LANGUAGE_ca, /* 11/120 Catalan */ "ca" , TEXTS_ca, /* 11/120 Catalan */
"cs", LANGUAGE_cs, /* 17/ 21 Czech */ "cs" , TEXTS_cs, /* 17/ 21 Czech */
"da", LANGUAGE_da, /* 19/ 33 Danish */ "da" , TEXTS_da, /* 19/ 33 Danish */
"de", LANGUAGE_de, /* 16/ 91 German */ "de" , TEXTS_de, /* 16/ 91 German */
"el", LANGUAGE_el, /* 1/ 10 Greek */ "el" , TEXTS_el, /* 1/ 10 Greek */
"en", LANGUAGE_en, /* 8/ 11 English */ "en" , TEXTS_en, /* 8/ 11 English */
"eo", LANGUAGE_eo, /* 26/115 Esperanto */ "eo" , TEXTS_eo, /* 26/115 Esperanto */
"es", LANGUAGE_es, /* 8/ 55 Spanish */ "es" , TEXTS_es, /* 8/ 55 Spanish */
"et", LANGUAGE_et_EE, /* 22/ 27 Estonian (Estonia) */ "et_EE" , TEXTS_et_EE, /* 22/ 27 Estonian (Estonia) */
"eu", LANGUAGE_eu_ES, /* 7/ 8 Basque (Spain) */ "eu_ES" , TEXTS_eu_ES, /* 7/ 8 Basque (Spain) */
"fa", LANGUAGE_fa, /* 58/123 Persian */ "fa" , TEXTS_fa, /* 58/123 Persian */
"fi", LANGUAGE_fi, /* 10/ 33 Finnish */ "fi" , TEXTS_fi, /* 10/ 33 Finnish */
"fr", LANGUAGE_fr, /* 13/ 91 French */ "fr" , TEXTS_fr, /* 13/ 91 French */
"gl", LANGUAGE_gl_ES, /* 7/ 8 Gallegan (Spain) */ "gl_ES" , TEXTS_gl_ES, /* 7/ 8 Gallegan (Spain) */
"hi", LANGUAGE_hi, /* 23/ 54 Hindi */ "hi" , TEXTS_hi, /* 23/ 54 Hindi */
"hr", LANGUAGE_hr, /* 9/ 19 Croatian */ "hr" , TEXTS_hr, /* 9/ 19 Croatian */
"hu", LANGUAGE_hu, /* 9/ 19 Hungarian */ "hu" , TEXTS_hu, /* 9/ 19 Hungarian */
"hy", LANGUAGE_hy_AM, /* 8/126 Armenian (Armenia) */ "hy_AM" , TEXTS_hy_AM, /* 8/126 Armenian (Armenia) */
"is", LANGUAGE_is, /* 10/ 15 Icelandic */ "is" , TEXTS_is, /* 10/ 15 Icelandic */
"it", LANGUAGE_it, /* 5/ 5 Italian */ "it" , TEXTS_it, /* 5/ 5 Italian */
"iw", LANGUAGE_iw, /* 20/121 Hebrew */ "iw" , TEXTS_iw, /* 20/121 Hebrew */
"ka", LANGUAGE_ka_GE, /* 3/ 10 Georgian (Georgia) */ "ka_GE" , TEXTS_ka_GE, /* 3/ 10 Georgian (Georgia) */
"kk", LANGUAGE_kk, /* 15/118 Kazakh */ "kk" , TEXTS_kk, /* 15/118 Kazakh */
"km", LANGUAGE_km_KH, /* 2/119 Khmer (Cambodia) */ "km_KH" , TEXTS_km_KH, /* 2/119 Khmer (Cambodia) */
"ky", LANGUAGE_ky, /* 10/ 80 Kirghiz */ "ky" , TEXTS_ky, /* 10/ 80 Kirghiz */
"lo", LANGUAGE_lo_LA, /* 2/ 20 Lao (Laos) */ "lo_LA" , TEXTS_lo_LA, /* 2/ 20 Lao (Laos) */
"lt", LANGUAGE_lt, /* 18/ 22 Lithuanian */ "lt" , TEXTS_lt, /* 18/ 22 Lithuanian */
"lv", LANGUAGE_lv, /* 18/ 22 Latvian */ "lv" , TEXTS_lv, /* 18/ 22 Latvian */
"mk", LANGUAGE_mk, /* 9/ 85 Macedonian */ "mk" , TEXTS_mk, /* 9/ 85 Macedonian */
"mn", LANGUAGE_mn_MN, /* 2/ 20 Mongolian (Mongolia) */ "mn_MN" , TEXTS_mn_MN, /* 2/ 20 Mongolian (Mongolia) */
"my", LANGUAGE_my_MM, /* 1/ 10 Burmese (Myanmar) */ "my_MM" , TEXTS_my_MM, /* 1/ 10 Burmese (Myanmar) */
"nb", LANGUAGE_nb, /* 11/ 33 Norwegian Bokmål */ "nb" , TEXTS_nb, /* 11/ 33 Norwegian Bokmål */
"ne", LANGUAGE_ne_NP, /* 23/ 54 Nepali (Nepal) */ "ne_NP" , TEXTS_ne_NP, /* 23/ 54 Nepali (Nepal) */
"nl", LANGUAGE_nl, /* 9/ 12 Dutch */ "nl" , TEXTS_nl, /* 9/ 12 Dutch */
"pl", LANGUAGE_pl, /* 10/ 16 Polish */ "pl" , TEXTS_pl, /* 10/ 16 Polish */
"pt", LANGUAGE_pt, /* 6/ 6 Portuguese */ "pt" , TEXTS_pt, /* 6/ 6 Portuguese */
"rm", LANGUAGE_rm, /* 1/ 2 Raeto-Romance */ "rm" , TEXTS_rm, /* 1/ 2 Raeto-Romance */
"ro", LANGUAGE_ro, /* 6/ 15 Romanian */ "ro" , TEXTS_ro, /* 6/ 15 Romanian */
"ru", LANGUAGE_ru, /* 9/ 32 Russian */ "ru" , TEXTS_ru, /* 9/ 32 Russian */
"sk", LANGUAGE_sk, /* 20/ 22 Slovak */ "sk" , TEXTS_sk, /* 20/ 22 Slovak */
"sl", LANGUAGE_sl, /* 8/ 19 Slovenian */ "sl" , TEXTS_sl, /* 8/ 19 Slovenian */
"sr", LANGUAGE_sr, /* 11/ 85 Serbian */ "sr" , TEXTS_sr, /* 11/ 85 Serbian */
"sv", LANGUAGE_sv, /* 21/ 33 Swedish */ "sv" , TEXTS_sv, /* 21/ 33 Swedish */
"sw", LANGUAGE_sw, /* 9/ 17 Swahili */ "sw" , TEXTS_sw, /* 9/ 17 Swahili */
"th", LANGUAGE_th, /* 2/ 20 Thai */ "th" , TEXTS_th, /* 2/ 20 Thai */
"tl", LANGUAGE_tl, /* 7/ 8 Tagalog */ "tl" , TEXTS_tl, /* 7/ 8 Tagalog */
"tr", LANGUAGE_tr, /* 7/ 17 Turkish */ "tr" , TEXTS_tr, /* 7/ 17 Turkish */
"uk", LANGUAGE_uk, /* 11/ 79 Ukrainian */ "uk" , TEXTS_uk, /* 11/ 79 Ukrainian */
"vi", LANGUAGE_vi, /* 8/ 20 Vietnamese */ "vi" , TEXTS_vi, /* 8/ 20 Vietnamese */
"zu", LANGUAGE_zu, /* 8/ 11 Zulu */ "zu" , TEXTS_zu, /* 8/ 11 Zulu */
"zz", LANGUAGE_zz, /* 19/109 Alphabet */ "zz" , TEXTS_zz, /* 19/109 Alphabet */
}; };
static { static {
@ -3714,11 +3720,11 @@ public final class KeyboardTextsTable {
sNameToIndexesMap.put(NAMES[index], index); sNameToIndexesMap.put(NAMES[index], index);
} }
for (int i = 0; i < LANGUAGES_AND_TEXTS.length; i += 2) { for (int i = 0; i < LOCALES_AND_TEXTS.length; i += 2) {
final String language = (String)LANGUAGES_AND_TEXTS[i]; final String locale = (String)LOCALES_AND_TEXTS[i];
final String[] textsTable = (String[])LANGUAGES_AND_TEXTS[i + 1]; final String[] textsTable = (String[])LOCALES_AND_TEXTS[i + 1];
sLanguageToTextsTableMap.put(language, textsTable); sLocaleToTextsTableMap.put(locale, textsTable);
sTextsTableToLanguageMap.put(textsTable, language); sTextsTableToLocaleMap.put(textsTable, locale);
} }
} }
} }

View File

@ -19,6 +19,7 @@ package com.android.inputmethod.keyboard.internal;
import com.android.inputmethod.latin.utils.CollectionUtils; import com.android.inputmethod.latin.utils.CollectionUtils;
import java.util.HashMap; import java.util.HashMap;
import java.util.Locale;
/** /**
* !!!!! DO NOT EDIT THIS FILE !!!!! * !!!!! DO NOT EDIT THIS FILE !!!!!
@ -44,19 +45,19 @@ import java.util.HashMap;
public final class KeyboardTextsTable { public final class KeyboardTextsTable {
// Name to index map. // Name to index map.
private static final HashMap<String, Integer> sNameToIndexesMap = CollectionUtils.newHashMap(); private static final HashMap<String, Integer> sNameToIndexesMap = CollectionUtils.newHashMap();
// Language to texts table map. // Locale to texts table map.
private static final HashMap<String, String[]> sLanguageToTextsTableMap = private static final HashMap<String, String[]> sLocaleToTextsTableMap =
CollectionUtils.newHashMap(); CollectionUtils.newHashMap();
// TODO: Remove this variable after debugging. // TODO: Remove this variable after debugging.
// Texts table to language maps. // Texts table to locale maps.
private static final HashMap<String[], String> sTextsTableToLanguageMap = private static final HashMap<String[], String> sTextsTableToLocaleMap =
CollectionUtils.newHashMap(); CollectionUtils.newHashMap();
public static String getText(final String name, final String[] textsTable) { public static String getText(final String name, final String[] textsTable) {
final Integer indexObj = sNameToIndexesMap.get(name); final Integer indexObj = sNameToIndexesMap.get(name);
if (indexObj == null) { if (indexObj == null) {
throw new RuntimeException("Unknown text name=" + name + " language=" throw new RuntimeException("Unknown text name=" + name + " locale="
+ sTextsTableToLanguageMap.get(textsTable)); + sTextsTableToLocaleMap.get(textsTable));
} }
final int index = indexObj; final int index = indexObj;
final String text = (index < textsTable.length) ? textsTable[index] : null; final String text = (index < textsTable.length) ? textsTable[index] : null;
@ -64,17 +65,24 @@ public final class KeyboardTextsTable {
return text; return text;
} }
// Sanity check. // Sanity check.
if (index >= 0 && index < LANGUAGE_DEFAULT.length) { if (index >= 0 && index < TEXTS_DEFAULT.length) {
return LANGUAGE_DEFAULT[index]; return TEXTS_DEFAULT[index];
} }
// Throw exception for debugging purpose. // Throw exception for debugging purpose.
throw new RuntimeException("Illegal index=" + index + " for name=" + name throw new RuntimeException("Illegal index=" + index + " for name=" + name
+ " language=" + sTextsTableToLanguageMap.get(textsTable)); + " locale=" + sTextsTableToLocaleMap.get(textsTable));
} }
public static String[] getTextsTable(final String language) { public static String[] getTextsTable(final Locale locale) {
final String[] textsTable = sLanguageToTextsTableMap.get(language); final String localeKey = locale.toString();
return textsTable != null ? textsTable : LANGUAGE_DEFAULT; if (sLocaleToTextsTableMap.containsKey(localeKey)) {
return sLocaleToTextsTableMap.get(localeKey);
}
final String languageKey = locale.getLanguage();
if (sLocaleToTextsTableMap.containsKey(languageKey)) {
return sLocaleToTextsTableMap.get(languageKey);
}
return TEXTS_DEFAULT;
} }
private static final String[] NAMES = { private static final String[] NAMES = {
@ -85,16 +93,14 @@ public final class KeyboardTextsTable {
private static final String EMPTY = ""; private static final String EMPTY = "";
/* Default texts */ /* Default texts */
private static final String[] LANGUAGE_DEFAULT = { private static final String[] TEXTS_DEFAULT = {
/* @DEFAULT_TEXTS@ */ /* @DEFAULT_TEXTS@ */
}; };
/* @TEXTS@ */ /* @TEXTS@ */
// TODO: Use the language + "_" + region representation for the locale string key. private static final Object[] LOCALES_AND_TEXTS = {
// Currently we are dropping the region from the key.
private static final Object[] LANGUAGES_AND_TEXTS = {
// "locale", TEXT_ARRAY, /* numberOfNonNullText/lengthOf_TEXT_ARRAY localeName */ // "locale", TEXT_ARRAY, /* numberOfNonNullText/lengthOf_TEXT_ARRAY localeName */
/* @LANGUAGES_AND_TEXTS@ */ /* @LOCALES_AND_TEXTS@ */
}; };
static { static {
@ -102,11 +108,11 @@ public final class KeyboardTextsTable {
sNameToIndexesMap.put(NAMES[index], index); sNameToIndexesMap.put(NAMES[index], index);
} }
for (int i = 0; i < LANGUAGES_AND_TEXTS.length; i += 2) { for (int i = 0; i < LOCALES_AND_TEXTS.length; i += 2) {
final String language = (String)LANGUAGES_AND_TEXTS[i]; final String locale = (String)LOCALES_AND_TEXTS[i];
final String[] textsTable = (String[])LANGUAGES_AND_TEXTS[i + 1]; final String[] textsTable = (String[])LOCALES_AND_TEXTS[i + 1];
sLanguageToTextsTableMap.put(language, textsTable); sLocaleToTextsTableMap.put(locale, textsTable);
sTextsTableToLanguageMap.put(textsTable, language); sTextsTableToLocaleMap.put(textsTable, locale);
} }
} }
} }

View File

@ -85,24 +85,24 @@ public final class JarUtils {
}); });
} }
// The language is taken from string resource jar entry name (values-<language>/) // The locale is taken from string resource jar entry name (values-<locale>/)
// or {@link LocaleUtils#DEFAULT_LANGUAGE_NAME} for the default string resource // or {@link LocaleUtils#DEFAULT_LOCALE_KEY} for the default string resource
// directory (values/). // directory (values/).
public static String getLanguageFromEntryName(final String jarEntryName) { public static String getLocaleFromEntryName(final String jarEntryName) {
final String dirName = jarEntryName.substring(0, jarEntryName.lastIndexOf('/')); final String dirName = jarEntryName.substring(0, jarEntryName.lastIndexOf('/'));
final int pos = dirName.lastIndexOf('/'); final int pos = dirName.lastIndexOf('/');
final String parentName = (pos >= 0) ? dirName.substring(pos + 1) : dirName; final String parentName = (pos >= 0) ? dirName.substring(pos + 1) : dirName;
final int languagePos = parentName.indexOf('-'); final int localePos = parentName.indexOf('-');
if (languagePos < 0) { if (localePos < 0) {
// Default resource name. // Default resource name.
return LocaleUtils.DEFAULT_LANGUAGE_NAME; return LocaleUtils.DEFAULT_LOCALE_KEY;
} }
final String language = parentName.substring(languagePos + 1); final String locale = parentName.substring(localePos + 1);
final int countryPos = language.indexOf("-r"); final int regionPos = locale.indexOf("-r");
if (countryPos < 0) { if (regionPos < 0) {
return language; return locale;
} }
return language.replace("-r", "_"); return locale.replace("-r", "_");
} }
public static void close(final Closeable stream) { public static void close(final Closeable stream) {

View File

@ -26,9 +26,9 @@ import java.util.Locale;
* for the make-keyboard-text tool. * for the make-keyboard-text tool.
*/ */
public final class LocaleUtils { public final class LocaleUtils {
public static final String DEFAULT_LANGUAGE_NAME = "DEFAULT"; public static final String DEFAULT_LOCALE_KEY = "DEFAULT";
public static final String NO_LANGUAGE_CODE = "zz"; public static final String NO_LANGUAGE_LOCALE_CODE = "zz";
public static final String NO_LANGUAGE_DISPLAY_NAME = "Alphabet"; public static final String NO_LANGUAGE_LOCALE_DISPLAY_NAME = "Alphabet";
private LocaleUtils() { private LocaleUtils() {
// Intentional empty constructor for utility class. // Intentional empty constructor for utility class.
@ -48,7 +48,8 @@ public final class LocaleUtils {
if (retval != null) { if (retval != null) {
return retval; return retval;
} }
String[] localeParams = localeStr.split("_", 3); final String[] localeParams = localeStr.split("_", 3);
// TODO: Use JDK 7 Locale.Builder to handle a script name.
if (localeParams.length == 1) { if (localeParams.length == 1) {
retval = new Locale(localeParams[0]); retval = new Locale(localeParams[0]);
} else if (localeParams.length == 2) { } else if (localeParams.length == 2) {
@ -63,11 +64,11 @@ public final class LocaleUtils {
} }
} }
public static String getLanguageDisplayName(final String language) { public static String getLocaleDisplayName(final String localeString) {
if (language.equals(NO_LANGUAGE_CODE)) { if (localeString.equals(NO_LANGUAGE_LOCALE_CODE)) {
return NO_LANGUAGE_DISPLAY_NAME; return NO_LANGUAGE_LOCALE_DISPLAY_NAME;
} }
final Locale locale = constructLocaleFromString(language); final Locale locale = constructLocaleFromString(localeString);
return locale.getDisplayName(Locale.ENGLISH); return locale.getDisplayName(Locale.ENGLISH);
} }
} }

View File

@ -25,7 +25,6 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.HashMap; import java.util.HashMap;
import java.util.Locale;
import java.util.TreeMap; import java.util.TreeMap;
import java.util.jar.JarFile; import java.util.jar.JarFile;
@ -36,12 +35,13 @@ public class MoreKeysResources {
private static final String MARK_NAMES = "@NAMES@"; private static final String MARK_NAMES = "@NAMES@";
private static final String MARK_DEFAULT_TEXTS = "@DEFAULT_TEXTS@"; private static final String MARK_DEFAULT_TEXTS = "@DEFAULT_TEXTS@";
private static final String MARK_TEXTS = "@TEXTS@"; private static final String MARK_TEXTS = "@TEXTS@";
private static final String MARK_LANGUAGES_AND_TEXTS = "@LANGUAGES_AND_TEXTS@"; private static final String TEXTS_ARRAY_NAME_PREFIX = "TEXTS_";
private static final String MARK_LOCALES_AND_TEXTS = "@LOCALES_AND_TEXTS@";
private static final String EMPTY_STRING_VAR = "EMPTY"; private static final String EMPTY_STRING_VAR = "EMPTY";
private final JarFile mJar; private final JarFile mJar;
// String resources maps sorted by its language. The language is determined from the jar entry // String resources maps sorted by its language. The language is determined from the jar entry
// name by calling {@link JarUtils#getLanguegFromEntryName(String)}. // name by calling {@link JarUtils#getLocaleFromEntryName(String)}.
private final TreeMap<String, StringResourceMap> mResourcesMap = private final TreeMap<String, StringResourceMap> mResourcesMap =
new TreeMap<String, StringResourceMap>(); new TreeMap<String, StringResourceMap>();
// Default string resources map. // Default string resources map.
@ -60,9 +60,9 @@ public class MoreKeysResources {
jar, TEXT_RESOURCE_NAME); jar, TEXT_RESOURCE_NAME);
for (final String entryName : resourceEntryNames) { for (final String entryName : resourceEntryNames) {
final StringResourceMap resMap = new StringResourceMap(entryName); final StringResourceMap resMap = new StringResourceMap(entryName);
mResourcesMap.put(resMap.mLanguage, resMap); mResourcesMap.put(resMap.mLocale, resMap);
} }
mDefaultResourceMap = mResourcesMap.get(LocaleUtils.DEFAULT_LANGUAGE_NAME); mDefaultResourceMap = mResourcesMap.get(LocaleUtils.DEFAULT_LOCALE_KEY);
// Initialize name histogram and names list. // Initialize name histogram and names list.
final HashMap<String, Integer> nameHistogram = mNameHistogram; final HashMap<String, Integer> nameHistogram = mNameHistogram;
@ -72,12 +72,12 @@ public class MoreKeysResources {
resourceNamesList.add(res.mName); resourceNamesList.add(res.mName);
} }
// Make name histogram. // Make name histogram.
for (final String language : mResourcesMap.keySet()) { for (final String locale : mResourcesMap.keySet()) {
final StringResourceMap resMap = mResourcesMap.get(language); final StringResourceMap resMap = mResourcesMap.get(locale);
if (resMap == mDefaultResourceMap) continue; if (resMap == mDefaultResourceMap) continue;
for (final StringResource res : resMap.getResources()) { for (final StringResource res : resMap.getResources()) {
if (!mDefaultResourceMap.contains(res.mName)) { if (!mDefaultResourceMap.contains(res.mName)) {
throw new RuntimeException(res.mName + " in " + language throw new RuntimeException(res.mName + " in " + locale
+ " doesn't have default resource"); + " doesn't have default resource");
} }
final int histogramValue = nameHistogram.get(res.mName); final int histogramValue = nameHistogram.get(res.mName);
@ -143,8 +143,8 @@ public class MoreKeysResources {
dumpDefaultTexts(out); dumpDefaultTexts(out);
} else if (line.contains(MARK_TEXTS)) { } else if (line.contains(MARK_TEXTS)) {
dumpTexts(out); dumpTexts(out);
} else if (line.contains(MARK_LANGUAGES_AND_TEXTS)) { } else if (line.contains(MARK_LOCALES_AND_TEXTS)) {
dumpLanguageMap(out); dumpLocalesMap(out);
} else { } else {
out.println(line); out.println(line);
} }
@ -165,17 +165,17 @@ public class MoreKeysResources {
mDefaultResourceMap.setOutputArraySize(outputArraySize); mDefaultResourceMap.setOutputArraySize(outputArraySize);
} }
private static String getArrayNameForLanguage(final String language) { private static String getArrayNameForLocale(final String locale) {
return "LANGUAGE_" + language; return TEXTS_ARRAY_NAME_PREFIX + locale;
} }
private void dumpTexts(final PrintStream out) { private void dumpTexts(final PrintStream out) {
for (final StringResourceMap resMap : mResourcesMap.values()) { for (final StringResourceMap resMap : mResourcesMap.values()) {
final String language = resMap.mLanguage; final String locale = resMap.mLocale;
if (resMap == mDefaultResourceMap) continue; if (resMap == mDefaultResourceMap) continue;
out.format(" /* Language %s: %s */\n", out.format(" /* Locale %s: %s */\n",
language, LocaleUtils.getLanguageDisplayName(language)); locale, LocaleUtils.getLocaleDisplayName(locale));
out.format(" private static final String[] " + getArrayNameForLanguage(language) out.format(" private static final String[] " + getArrayNameForLocale(locale)
+ " = {\n"); + " = {\n");
final int outputArraySize = dumpTextsInternal(out, resMap); final int outputArraySize = dumpTextsInternal(out, resMap);
resMap.setOutputArraySize(outputArraySize); resMap.setOutputArraySize(outputArraySize);
@ -183,17 +183,16 @@ public class MoreKeysResources {
} }
} }
private void dumpLanguageMap(final PrintStream out) { private void dumpLocalesMap(final PrintStream out) {
for (final StringResourceMap resMap : mResourcesMap.values()) { for (final StringResourceMap resMap : mResourcesMap.values()) {
final String language = resMap.mLanguage; final String locale = resMap.mLocale;
final Locale locale = LocaleUtils.constructLocaleFromString(language); final String localeToDump = locale.equals(LocaleUtils.DEFAULT_LOCALE_KEY)
final String languageKeyToDump = locale.getCountry().isEmpty() ? String.format("\"%s\"", locale)
? String.format("\"%s\"", language) : String.format("\"%s\"%s", locale, " ".substring(locale.length()));
: String.format("\"%s\"", locale.getLanguage()); out.format(" %s, %-12s /* %3d/%3d %s */\n",
out.format(" %s, %-15s /* %3d/%3d %s */\n", localeToDump, getArrayNameForLocale(locale) + ",",
languageKeyToDump, getArrayNameForLanguage(language) + ",",
resMap.getResources().size(), resMap.getOutputArraySize(), resMap.getResources().size(), resMap.getOutputArraySize(),
LocaleUtils.getLanguageDisplayName(language)); LocaleUtils.getLocaleDisplayName(locale));
} }
} }

View File

@ -34,8 +34,8 @@ import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory; import javax.xml.parsers.SAXParserFactory;
public class StringResourceMap { public class StringResourceMap {
// Lanugage name. // Locale name.
public final String mLanguage; public final String mLocale;
// String resource list. // String resource list.
private final List<StringResource> mResources; private final List<StringResource> mResources;
// Name to string resource map. // Name to string resource map.
@ -44,11 +44,11 @@ public class StringResourceMap {
// The length of String[] that is created from this {@link StringResourceMap}. The length is // The length of String[] that is created from this {@link StringResourceMap}. The length is
// calculated in {@link MoreKeysResources#dumpTexts(OutputStream)} and recorded by // calculated in {@link MoreKeysResources#dumpTexts(OutputStream)} and recorded by
// {@link #setOutputArraySize(int)}. The recorded length is used as a part of comment by // {@link #setOutputArraySize(int)}. The recorded length is used as a part of comment by
// {@link MoreKeysResources#dumpLanguageMap(OutputStream)} via {@link #getOutputArraySize()}. // {@link MoreKeysResources#dumpLocaleMap(OutputStream)} via {@link #getOutputArraySize()}.
private int mOutputArraySize; private int mOutputArraySize;
public StringResourceMap(final String jarEntryName) { public StringResourceMap(final String jarEntryName) {
mLanguage = JarUtils.getLanguageFromEntryName(jarEntryName); mLocale = JarUtils.getLocaleFromEntryName(jarEntryName);
final StringResourceHandler handler = new StringResourceHandler(); final StringResourceHandler handler = new StringResourceHandler();
final SAXParserFactory factory = SAXParserFactory.newInstance(); final SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setNamespaceAware(true); factory.setNamespaceAware(true);