aboutsummaryrefslogtreecommitdiffstats
path: root/tools/make-keyboard-text/res/src
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2014-02-21 19:24:24 +0900
committerTadashi G. Takaoka <takaoka@google.com>2014-02-21 19:24:24 +0900
commit5eb6ea9f27f2486c6688551bc0a117ec39bfe5a0 (patch)
treef5712e925b27926572931548718b8c86ff4f5477 /tools/make-keyboard-text/res/src
parentad508d029f7fbd225f41f3b2a0b7134bd90c37ba (diff)
downloadlatinime-5eb6ea9f27f2486c6688551bc0a117ec39bfe5a0.tar.gz
latinime-5eb6ea9f27f2486c6688551bc0a117ec39bfe5a0.tar.xz
latinime-5eb6ea9f27f2486c6688551bc0a117ec39bfe5a0.zip
Change make-keyboard-text -java option to point LatinIME/java directory
Change-Id: I812713da5918049c0e504e48bd0693df2f7bf46d
Diffstat (limited to 'tools/make-keyboard-text/res/src')
-rw-r--r--tools/make-keyboard-text/res/src/com/android/inputmethod/keyboard/internal/KeyboardTextsTable.tmpl112
1 files changed, 112 insertions, 0 deletions
diff --git a/tools/make-keyboard-text/res/src/com/android/inputmethod/keyboard/internal/KeyboardTextsTable.tmpl b/tools/make-keyboard-text/res/src/com/android/inputmethod/keyboard/internal/KeyboardTextsTable.tmpl
new file mode 100644
index 000000000..b25bfb204
--- /dev/null
+++ b/tools/make-keyboard-text/res/src/com/android/inputmethod/keyboard/internal/KeyboardTextsTable.tmpl
@@ -0,0 +1,112 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.inputmethod.keyboard.internal;
+
+import com.android.inputmethod.latin.utils.CollectionUtils;
+
+import java.util.HashMap;
+
+/**
+ * !!!!! DO NOT EDIT THIS FILE !!!!!
+ *
+ * This file is generated by tools/make-keyboard-text. The base template file is
+ * tools/make-keyboard-text/res/src/com/android/inputmethod/keyboard/internal/
+ * KeyboardTextsTable.tmpl
+ *
+ * This file must be updated when any text resources in keyboard layout files have been changed.
+ * These text resources are referred as "!text/<resource_name>" in keyboard XML definitions,
+ * and should be defined in
+ * tools/make-keyboard-text/res/values-<locale>/donottranslate-more-keys.xml
+ *
+ * To update this file, please run the following commands.
+ * $ cd $ANDROID_BUILD_TOP
+ * $ mmm packages/inputmethods/LatinIME/tools/make-keyboard-text
+ * $ make-keyboard-text -java packages/inputmethods/LatinIME/java
+ *
+ * The updated source file will be generated to the following path (this file).
+ * packages/inputmethods/LatinIME/java/src/com/android/inputmethod/keyboard/internal/
+ * KeyboardTextsTable.java
+ */
+public final class KeyboardTextsTable {
+ // Name to index map.
+ private static final HashMap<String, Integer> sNameToIndexesMap = CollectionUtils.newHashMap();
+ // 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 + " language="
+ + sTextsTableToLanguageMap.get(textsTable));
+ }
+ final int index = indexObj;
+ final String text = (index < textsTable.length) ? textsTable[index] : null;
+ 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 = sLanguageToTextsTableMap.get(language);
+ return textsTable != null ? textsTable : LANGUAGE_DEFAULT;
+ }
+
+ private static final String[] NAMES = {
+ // /* index:histogram */ "name",
+ /* @NAMES@ */
+ };
+
+ private static final String EMPTY = "";
+
+ /* Default texts */
+ private static final String[] LANGUAGE_DEFAULT = {
+ /* @DEFAULT_TEXTS@ */
+ };
+
+ /* @TEXTS@ */
+ // TODO: Use the language + "_" + region representation for the locale string key.
+ // Currently we are dropping the region from the key.
+ private static final Object[] LANGUAGES_AND_TEXTS = {
+ // "locale", TEXT_ARRAY, /* numberOfNonNullText/lengthOf_TEXT_ARRAY localeName */
+ /* @LANGUAGES_AND_TEXTS@ */
+ };
+
+ static {
+ for (int index = 0; index < NAMES.length; index++) {
+ sNameToIndexesMap.put(NAMES[index], index);
+ }
+
+ for (int i = 0; i < LANGUAGES_AND_TEXTS.length; i += 2) {
+ final String language = (String)LANGUAGES_AND_TEXTS[i];
+ final String[] textsTable = (String[])LANGUAGES_AND_TEXTS[i + 1];
+ sLanguageToTextsTableMap.put(language, textsTable);
+ sTextsTableToLanguageMap.put(textsTable, language);
+ }
+ }
+}