diff options
Diffstat (limited to 'tools/make-keyboard-text')
9 files changed, 40 insertions, 42 deletions
diff --git a/tools/make-keyboard-text/res/com/android/inputmethod/keyboard/internal/KeyboardTextsTable.tmpl b/tools/make-keyboard-text/res/com/android/inputmethod/keyboard/internal/KeyboardTextsTable.tmpl index f56cfd91b..7ec42ceea 100644 --- a/tools/make-keyboard-text/res/com/android/inputmethod/keyboard/internal/KeyboardTextsTable.tmpl +++ b/tools/make-keyboard-text/res/com/android/inputmethod/keyboard/internal/KeyboardTextsTable.tmpl @@ -43,22 +43,36 @@ import java.util.HashMap; public final class KeyboardTextsTable { // Name to index map. private static final HashMap<String, Integer> sNameToIndexesMap = CollectionUtils.newHashMap(); - // Language to texts map. - private static final HashMap<String, String[]> sLanguageToTextsMap = + // Language to texts table map. + private static final HashMap<String, String[]> sLanguageToTextsTableMap = + CollectionUtils.newHashMap(); + // TODO: Remove this variable after debugging. + // Texts table to language maps. + private static final HashMap<String[], String> sTextsTableToLanguageMap = CollectionUtils.newHashMap(); public static String getText(final String name, final String[] textsTable) { final Integer indexObj = sNameToIndexesMap.get(name); if (indexObj == null) { - throw new RuntimeException("Unknown text name: " + name); + throw new RuntimeException("Unknown text name=" + name + " language=" + + sTextsTableToLanguageMap.get(textsTable)); } final int index = indexObj; final String text = (index < textsTable.length) ? textsTable[index] : null; - return (text != null) ? text : LANGUAGE_DEFAULT[index]; + if (text != null) { + return text; + } + // Sanity check. + if (index >= 0 && index < LANGUAGE_DEFAULT.length) { + return LANGUAGE_DEFAULT[index]; + } + // Throw exception for debugging purpose. + throw new RuntimeException("Illegal index=" + index + " for name=" + name + + " language=" + sTextsTableToLanguageMap.get(textsTable)); } public static String[] getTextsTable(final String language) { - final String[] textsTable = sLanguageToTextsMap.get(language); + final String[] textsTable = sLanguageToTextsTableMap.get(language); return textsTable != null ? textsTable : LANGUAGE_DEFAULT; } @@ -89,8 +103,9 @@ public final class KeyboardTextsTable { for (int i = 0; i < LANGUAGES_AND_TEXTS.length; i += 2) { final String language = (String)LANGUAGES_AND_TEXTS[i]; - final String[] texts = (String[])LANGUAGES_AND_TEXTS[i + 1]; - sLanguageToTextsMap.put(language, texts); + final String[] textsTable = (String[])LANGUAGES_AND_TEXTS[i + 1]; + sLanguageToTextsTableMap.put(language, textsTable); + sTextsTableToLanguageMap.put(textsTable, language); } } } diff --git a/tools/make-keyboard-text/res/values-ar/donottranslate-more-keys.xml b/tools/make-keyboard-text/res/values-ar/donottranslate-more-keys.xml index 9b0a05945..d9976858a 100644 --- a/tools/make-keyboard-text/res/values-ar/donottranslate-more-keys.xml +++ b/tools/make-keyboard-text/res/values-ar/donottranslate-more-keys.xml @@ -75,7 +75,7 @@ <!-- U+066A: "٪" ARABIC PERCENT SIGN --> <string name="keylabel_for_symbols_percent">٪</string> <!-- U+00BF: "¿" INVERTED QUESTION MARK --> - <string name="more_keys_for_question">\?,¿</string> + <string name="more_keys_for_question">?,¿</string> <string name="more_keys_for_symbols_semicolon">;</string> <!-- U+2030: "‰" PER MILLE SIGN --> <string name="more_keys_for_symbols_percent">\\%,‰</string> @@ -85,7 +85,7 @@ <string name="keylabel_for_tablet_comma">"،"</string> <string name="keyhintlabel_for_tablet_comma">"؟"</string> <string name="more_keys_for_tablet_comma">"!fixedColumnOrder!4,:,!,؟,؛,-,/,\",\'"</string> - <string name="more_keys_for_punctuation">"!fixedColumnOrder!8,\",\',#,-,:,!,،,؟,\@,&,\\%,+,؛,/,(|),)|("</string> + <string name="more_keys_for_punctuation">"!fixedColumnOrder!8,\",\',#,-,:,!,،,؟,@,&,\\%,+,؛,/,(|),)|("</string> <!-- U+266A: "♪" EIGHTH NOTE --> <string name="more_keys_for_bullet">♪</string> <!-- U+2605: "★" BLACK STAR diff --git a/tools/make-keyboard-text/res/values-ca/donottranslate-more-keys.xml b/tools/make-keyboard-text/res/values-ca/donottranslate-more-keys.xml index f63e85bd5..8865a6057 100644 --- a/tools/make-keyboard-text/res/values-ca/donottranslate-more-keys.xml +++ b/tools/make-keyboard-text/res/values-ca/donottranslate-more-keys.xml @@ -71,8 +71,8 @@ U+0142: "ł" LATIN SMALL LETTER L WITH STROKE --> <string name="more_keys_for_l">l·l,ł</string> <!-- U+00B7: "·" MIDDLE DOT --> - <string name="more_keys_for_punctuation">"!fixedColumnOrder!9,;,/,(,),#,·,!,\\,,\?,&,\\%,+,\",-,:,',\@"</string> - <string name="more_keys_for_tablet_punctuation">"!fixedColumnOrder!8,;,/,(,),#,·,',\\,,&,\\%,+,\",-,:,\@"</string> + <string name="more_keys_for_punctuation">"!fixedColumnOrder!9,;,/,(,),#,·,!,\\,,?,&,\\%,+,\",-,:,',@"</string> + <string name="more_keys_for_tablet_punctuation">"!fixedColumnOrder!8,;,/,(,),#,·,',\\,,&,\\%,+,\",-,:,@"</string> <!-- U+00E7: "ç" LATIN SMALL LETTER C WITH CEDILLA --> <string name="keylabel_for_spanish_row2_10">ç</string> </resources> diff --git a/tools/make-keyboard-text/res/values-es/donottranslate-more-keys.xml b/tools/make-keyboard-text/res/values-es/donottranslate-more-keys.xml index f4fe7f787..453d5c196 100644 --- a/tools/make-keyboard-text/res/values-es/donottranslate-more-keys.xml +++ b/tools/make-keyboard-text/res/values-es/donottranslate-more-keys.xml @@ -69,5 +69,5 @@ <string name="more_keys_for_c">ç,ć,č</string> <!-- U+00A1: "¡" INVERTED EXCLAMATION MARK U+00BF: "¿" INVERTED QUESTION MARK --> - <string name="more_keys_for_punctuation">"!fixedColumnOrder!9,¡,;,/,(,),#,!,\\,,\?,¿,&,\\%,+,\",-,:,',\@"</string> + <string name="more_keys_for_punctuation">"!fixedColumnOrder!9,¡,;,/,(,),#,!,\\,,?,¿,&,\\%,+,\",-,:,',@"</string> </resources> diff --git a/tools/make-keyboard-text/res/values-fa/donottranslate-more-keys.xml b/tools/make-keyboard-text/res/values-fa/donottranslate-more-keys.xml index 3f12784e5..6ea04338e 100644 --- a/tools/make-keyboard-text/res/values-fa/donottranslate-more-keys.xml +++ b/tools/make-keyboard-text/res/values-fa/donottranslate-more-keys.xml @@ -75,7 +75,7 @@ <!-- U+066A: "٪" ARABIC PERCENT SIGN --> <string name="keylabel_for_symbols_percent">٪</string> <!-- U+00BF: "¿" INVERTED QUESTION MARK --> - <string name="more_keys_for_question">\?,¿</string> + <string name="more_keys_for_question">?,¿</string> <string name="more_keys_for_symbols_semicolon">;</string> <!-- U+2030: "‰" PER MILLE SIGN --> <string name="more_keys_for_symbols_percent">\\%,‰</string> @@ -92,7 +92,7 @@ <!-- U+061F: "؟" ARABIC QUESTION MARK U+060C: "،" ARABIC COMMA U+061B: "؛" ARABIC SEMICOLON --> - <string name="more_keys_for_punctuation">"!fixedColumnOrder!8,\",\',#,-,:,!,،,؟,\@,&,\\%,+,؛,/,!text/keyspec_left_parenthesis,!text/keyspec_right_parenthesis"</string> + <string name="more_keys_for_punctuation">"!fixedColumnOrder!8,\",\',#,-,:,!,،,؟,@,&,\\%,+,؛,/,!text/keyspec_left_parenthesis,!text/keyspec_right_parenthesis"</string> <!-- U+266A: "♪" EIGHTH NOTE --> <string name="more_keys_for_bullet">♪</string> <!-- U+2605: "★" BLACK STAR diff --git a/tools/make-keyboard-text/res/values-hi/donottranslate-more-keys.xml b/tools/make-keyboard-text/res/values-hi/donottranslate-more-keys.xml index b0d010f81..de10a010f 100644 --- a/tools/make-keyboard-text/res/values-hi/donottranslate-more-keys.xml +++ b/tools/make-keyboard-text/res/values-hi/donottranslate-more-keys.xml @@ -44,7 +44,7 @@ <!-- U+0966: "०" DEVANAGARI DIGIT ZERO --> <string name="keylabel_for_symbols_0">०</string> <!-- Label for "switch to symbols" key. --> - <string name="label_to_symbol_key">\?१२३</string> + <string name="label_to_symbol_key">?१२३</string> <!-- Label for "switch to symbols with microphone" key. This string shouldn't include the "mic" part because it'll be appended by the code. --> <string name="label_to_symbol_with_microphone_key">१२३</string> diff --git a/tools/make-keyboard-text/res/values-ne-rNP/donottranslate-more-keys.xml b/tools/make-keyboard-text/res/values-ne-rNP/donottranslate-more-keys.xml index 9205e5309..e92a87e19 100644 --- a/tools/make-keyboard-text/res/values-ne-rNP/donottranslate-more-keys.xml +++ b/tools/make-keyboard-text/res/values-ne-rNP/donottranslate-more-keys.xml @@ -44,7 +44,7 @@ <!-- U+0966: "०" DEVANAGARI DIGIT ZERO --> <string name="keylabel_for_symbols_0">०</string> <!-- Label for "switch to symbols" key. --> - <string name="label_to_symbol_key">\?१२३</string> + <string name="label_to_symbol_key">?१२३</string> <!-- Label for "switch to symbols with microphone" key. This string shouldn't include the "mic" part because it'll be appended by the code. --> <string name="label_to_symbol_with_microphone_key">१२३</string> diff --git a/tools/make-keyboard-text/res/values/donottranslate-more-keys.xml b/tools/make-keyboard-text/res/values/donottranslate-more-keys.xml index 8d3d61c72..9cdcb4668 100644 --- a/tools/make-keyboard-text/res/values/donottranslate-more-keys.xml +++ b/tools/make-keyboard-text/res/values/donottranslate-more-keys.xml @@ -83,8 +83,8 @@ <string name="more_keys_for_currency_dollar">¢,£,€,¥,₱</string> <string name="keylabel_for_currency">$</string> <string name="more_keys_for_currency">$,¢,€,£,¥,₱</string> - <string name="more_keys_for_punctuation">"!fixedColumnOrder!8,;,/,!text/keyspec_left_parenthesis,!text/keyspec_right_parenthesis,#,!,\\,,\?,&,\\%,+,\",-,:,',\@"</string> - <string name="more_keys_for_tablet_punctuation">"!fixedColumnOrder!7,;,/,!text/keyspec_left_parenthesis,!text/keyspec_right_parenthesis,#,',\\,,&,\\%,+,\",-,:,\@"</string> + <string name="more_keys_for_punctuation">"!fixedColumnOrder!8,;,/,!text/keyspec_left_parenthesis,!text/keyspec_right_parenthesis,#,!,\\,,?,&,\\%,+,\",-,:,',@"</string> + <string name="more_keys_for_tablet_punctuation">"!fixedColumnOrder!7,;,/,!text/keyspec_left_parenthesis,!text/keyspec_right_parenthesis,#,',\\,,&,\\%,+,\",-,:,@"</string> <!-- U+00F1: "ñ" LATIN SMALL LETTER N WITH TILDE --> <string name="keylabel_for_spanish_row2_10">ñ</string> <!-- U+2020: "†" DAGGER @@ -115,7 +115,7 @@ <string name="keylabel_for_symbols_9">9</string> <string name="keylabel_for_symbols_0">0</string> <!-- Label for "switch to symbols" key. --> - <string name="label_to_symbol_key">\?123</string> + <string name="label_to_symbol_key">?123</string> <!-- Label for "switch to symbols with microphone" key. This string shouldn't include the "mic" part because it'll be appended by the code. --> <string name="label_to_symbol_with_microphone_key">123</string> @@ -189,7 +189,7 @@ <string name="keylabel_for_tablet_period">.</string> <string name="keyhintlabel_for_tablet_period"></string> <string name="more_keys_for_tablet_period">!text/more_keys_for_tablet_punctuation</string> - <string name="keylabel_for_symbols_question">\?</string> + <string name="keylabel_for_symbols_question">?</string> <string name="keylabel_for_symbols_semicolon">;</string> <string name="keylabel_for_symbols_percent">%</string> <!-- U+00A1: "¡" INVERTED EXCLAMATION MARK --> @@ -205,17 +205,15 @@ <string name="keylabel_for_w">w</string> <string name="keylabel_for_y">y</string> <string name="keylabel_for_x">x</string> - <string name="more_keys_for_am_pm">!fixedColumnOrder!2,!hasLabels!,\@string/label_time_am,\@string/label_time_pm</string> + <string name="more_keys_for_am_pm">!fixedColumnOrder!2,!hasLabels!,!text/label_time_am,!text/label_time_pm</string> <string name="settings_as_more_key">!icon/settings_key|!code/key_settings</string> <string name="shortcut_as_more_key">!icon/shortcut_key|!code/key_shortcut</string> - <string name="action_next_as_more_key">!hasLabels!,\@string/label_next_key|!code/key_action_next</string> - <string name="action_previous_as_more_key">!hasLabels!,\@string/label_previous_key|!code/key_action_previous</string> + <string name="action_next_as_more_key">!hasLabels!,!text/label_next_key|!code/key_action_next</string> + <string name="action_previous_as_more_key">!hasLabels!,!text/label_previous_key|!code/key_action_previous</string> <!-- Label for "switch to more symbol" modifier key ("= \ <"). Must be short to fit on key! --> <string name="label_to_more_symbol_key">= \\\\ <</string> <!-- Label for "switch to more symbol" modifier key on tablets. Must be short to fit on key! --> <string name="label_to_more_symbol_for_tablet_key">~ [ <</string> - <!-- Label for "Tab" key. Must be short to fit on key! --> - <string name="label_tab_key">Tab</string> <!-- Label for "switch to phone numeric" key. Must be short to fit on key! --> <string name="label_to_phone_numeric_key">123</string> <!-- Label for "switch to phone symbols" key. Must be short to fit on key! --> diff --git a/tools/make-keyboard-text/src/com/android/inputmethod/keyboard/tools/MoreKeysResources.java b/tools/make-keyboard-text/src/com/android/inputmethod/keyboard/tools/MoreKeysResources.java index 872ef19e3..e9d6c864f 100644 --- a/tools/make-keyboard-text/src/com/android/inputmethod/keyboard/tools/MoreKeysResources.java +++ b/tools/make-keyboard-text/src/com/android/inputmethod/keyboard/tools/MoreKeysResources.java @@ -29,6 +29,7 @@ import java.util.Comparator; import java.util.HashMap; import java.util.Locale; import java.util.jar.JarFile; +import java.util.regex.Pattern; public class MoreKeysResources { private static final String TEXT_RESOURCE_NAME = "donottranslate-more-keys.xml"; @@ -287,23 +288,7 @@ public class MoreKeysResources { sb.append(String.format("\\u%04X", (int)c)); } } - return replaceIncompatibleEscape(sb.toString()); - } - - private static String replaceIncompatibleEscape(final String text) { - String t = text; - t = replaceAll(t, "\\?", "?"); - t = replaceAll(t, "\\@", "@"); - t = replaceAll(t, "@string/", "!text/"); - return t; - } - - private static String replaceAll(final String text, final String target, final String replace) { - String t = text; - while (t.indexOf(target) >= 0) { - t = t.replace(target, replace); - } - return t; + return sb.toString(); } private static void close(final Closeable stream) { |