aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/make-keyboard-text/res/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.tmpl2
-rw-r--r--tools/make-keyboard-text/res/values-be-rBY/donottranslate-more-keys.xml (renamed from tools/make-keyboard-text/res/values-be/donottranslate-more-keys.xml)0
-rw-r--r--tools/make-keyboard-text/res/values-et-rEE/donottranslate-more-keys.xml (renamed from tools/make-keyboard-text/res/values-et/donottranslate-more-keys.xml)0
-rw-r--r--tools/make-keyboard-text/res/values-hy-rAM/donottranslate-more-keys.xml (renamed from tools/make-keyboard-text/res/values-hy/donottranslate-more-keys.xml)0
-rw-r--r--tools/make-keyboard-text/res/values-ka-rGE/donottranslate-more-keys.xml (renamed from tools/make-keyboard-text/res/values-ka/donottranslate-more-keys.xml)0
-rw-r--r--tools/make-keyboard-text/res/values-km-rKH/donottranslate-more-keys.xml (renamed from tools/make-keyboard-text/res/values-km/donottranslate-more-keys.xml)0
-rw-r--r--tools/make-keyboard-text/res/values-lo-rLA/donottranslate-more-keys.xml (renamed from tools/make-keyboard-text/res/values-lo/donottranslate-more-keys.xml)0
-rw-r--r--tools/make-keyboard-text/res/values-mn-rMN/donottranslate-more-keys.xml (renamed from tools/make-keyboard-text/res/values-mn/donottranslate-more-keys.xml)0
-rw-r--r--tools/make-keyboard-text/src/com/android/inputmethod/keyboard/tools/LocaleUtils.java61
-rw-r--r--tools/make-keyboard-text/src/com/android/inputmethod/keyboard/tools/MoreKeysResources.java33
10 files changed, 83 insertions, 13 deletions
diff --git a/tools/make-keyboard-text/res/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.tmpl b/tools/make-keyboard-text/res/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.tmpl
index 072daa4e9..a8ac981e0 100644
--- a/tools/make-keyboard-text/res/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.tmpl
+++ b/tools/make-keyboard-text/res/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.tmpl
@@ -113,6 +113,8 @@ public final class KeyboardTextsSet {
};
/* @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 = {
/* @LANGUAGES_AND_TEXTS@ */
};
diff --git a/tools/make-keyboard-text/res/values-be/donottranslate-more-keys.xml b/tools/make-keyboard-text/res/values-be-rBY/donottranslate-more-keys.xml
index 4723503f1..4723503f1 100644
--- a/tools/make-keyboard-text/res/values-be/donottranslate-more-keys.xml
+++ b/tools/make-keyboard-text/res/values-be-rBY/donottranslate-more-keys.xml
diff --git a/tools/make-keyboard-text/res/values-et/donottranslate-more-keys.xml b/tools/make-keyboard-text/res/values-et-rEE/donottranslate-more-keys.xml
index d037044bd..d037044bd 100644
--- a/tools/make-keyboard-text/res/values-et/donottranslate-more-keys.xml
+++ b/tools/make-keyboard-text/res/values-et-rEE/donottranslate-more-keys.xml
diff --git a/tools/make-keyboard-text/res/values-hy/donottranslate-more-keys.xml b/tools/make-keyboard-text/res/values-hy-rAM/donottranslate-more-keys.xml
index a94d50e53..a94d50e53 100644
--- a/tools/make-keyboard-text/res/values-hy/donottranslate-more-keys.xml
+++ b/tools/make-keyboard-text/res/values-hy-rAM/donottranslate-more-keys.xml
diff --git a/tools/make-keyboard-text/res/values-ka/donottranslate-more-keys.xml b/tools/make-keyboard-text/res/values-ka-rGE/donottranslate-more-keys.xml
index 8c2add44c..8c2add44c 100644
--- a/tools/make-keyboard-text/res/values-ka/donottranslate-more-keys.xml
+++ b/tools/make-keyboard-text/res/values-ka-rGE/donottranslate-more-keys.xml
diff --git a/tools/make-keyboard-text/res/values-km/donottranslate-more-keys.xml b/tools/make-keyboard-text/res/values-km-rKH/donottranslate-more-keys.xml
index c33831c56..c33831c56 100644
--- a/tools/make-keyboard-text/res/values-km/donottranslate-more-keys.xml
+++ b/tools/make-keyboard-text/res/values-km-rKH/donottranslate-more-keys.xml
diff --git a/tools/make-keyboard-text/res/values-lo/donottranslate-more-keys.xml b/tools/make-keyboard-text/res/values-lo-rLA/donottranslate-more-keys.xml
index 1d8ffa8cf..1d8ffa8cf 100644
--- a/tools/make-keyboard-text/res/values-lo/donottranslate-more-keys.xml
+++ b/tools/make-keyboard-text/res/values-lo-rLA/donottranslate-more-keys.xml
diff --git a/tools/make-keyboard-text/res/values-mn/donottranslate-more-keys.xml b/tools/make-keyboard-text/res/values-mn-rMN/donottranslate-more-keys.xml
index a7f366685..a7f366685 100644
--- a/tools/make-keyboard-text/res/values-mn/donottranslate-more-keys.xml
+++ b/tools/make-keyboard-text/res/values-mn-rMN/donottranslate-more-keys.xml
diff --git a/tools/make-keyboard-text/src/com/android/inputmethod/keyboard/tools/LocaleUtils.java b/tools/make-keyboard-text/src/com/android/inputmethod/keyboard/tools/LocaleUtils.java
new file mode 100644
index 000000000..9fdc1f607
--- /dev/null
+++ b/tools/make-keyboard-text/src/com/android/inputmethod/keyboard/tools/LocaleUtils.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2013 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.tools;
+
+import java.util.HashMap;
+import java.util.Locale;
+
+/**
+ * A class to help with handling Locales in string form.
+ *
+ * This is a subset of com/android/inputmethod/latin/utils/LocaleUtils.java in order to use
+ * for the make-keyboard-text tool.
+ */
+public final class LocaleUtils {
+ private LocaleUtils() {
+ // Intentional empty constructor for utility class.
+ }
+
+ private static final HashMap<String, Locale> sLocaleCache = new HashMap<String, Locale>();
+
+ /**
+ * Creates a locale from a string specification.
+ */
+ public static Locale constructLocaleFromString(final String localeStr) {
+ if (localeStr == null) {
+ return null;
+ }
+ synchronized (sLocaleCache) {
+ Locale retval = sLocaleCache.get(localeStr);
+ if (retval != null) {
+ return retval;
+ }
+ String[] localeParams = localeStr.split("_", 3);
+ if (localeParams.length == 1) {
+ retval = new Locale(localeParams[0]);
+ } else if (localeParams.length == 2) {
+ retval = new Locale(localeParams[0], localeParams[1]);
+ } else if (localeParams.length == 3) {
+ retval = new Locale(localeParams[0], localeParams[1], localeParams[2]);
+ }
+ if (retval != null) {
+ sLocaleCache.put(localeStr, retval);
+ }
+ return retval;
+ }
+ }
+}
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 2643e01ec..a88383025 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
@@ -37,7 +37,7 @@ public class MoreKeysResources {
private static final String MARK_DEFAULT_TEXTS = "@DEFAULT_TEXTS@";
private static final String MARK_TEXTS = "@TEXTS@";
private static final String MARK_LANGUAGES_AND_TEXTS = "@LANGUAGES_AND_TEXTS@";
- private static final String DEFAUT_LANGUAGE_NAME = "DEFAULT";
+ private static final String DEFAULT_LANGUAGE_NAME = "DEFAULT";
private static final String ARRAY_NAME_FOR_LANGUAGE = "LANGUAGE_%s";
private static final String EMPTY_STRING_VAR = "EMPTY";
@@ -72,7 +72,7 @@ public class MoreKeysResources {
final int languagePos = dirName.indexOf('-');
if (languagePos < 0) {
// Default resource.
- return DEFAUT_LANGUAGE_NAME;
+ return DEFAULT_LANGUAGE_NAME;
}
final String language = dirName.substring(languagePos + 1);
final int countryPos = language.indexOf("-r");
@@ -84,10 +84,12 @@ public class MoreKeysResources {
public void writeToJava(final String outDir) {
final ArrayList<String> list = JarUtils.getNameListing(mJar, JAVA_TEMPLATE);
- if (list.isEmpty())
+ if (list.isEmpty()) {
throw new RuntimeException("Can't find java template " + JAVA_TEMPLATE);
- if (list.size() > 1)
+ }
+ if (list.size() > 1) {
throw new RuntimeException("Found multiple java template " + JAVA_TEMPLATE);
+ }
final String template = list.get(0);
final String javaPackage = template.substring(0, template.lastIndexOf('/'));
PrintStream ps = null;
@@ -131,7 +133,7 @@ public class MoreKeysResources {
}
private void dumpNames(final PrintStream out) {
- final StringResourceMap defaultResMap = mResourcesMap.get(DEFAUT_LANGUAGE_NAME);
+ final StringResourceMap defaultResMap = mResourcesMap.get(DEFAULT_LANGUAGE_NAME);
int id = 0;
for (final StringResource res : defaultResMap.getResources()) {
out.format(" /* %2d */ \"%s\",\n", id, res.mName);
@@ -141,17 +143,17 @@ public class MoreKeysResources {
}
private void dumpDefaultTexts(final PrintStream out) {
- final StringResourceMap defaultResMap = mResourcesMap.get(DEFAUT_LANGUAGE_NAME);
+ final StringResourceMap defaultResMap = mResourcesMap.get(DEFAULT_LANGUAGE_NAME);
dumpTextsInternal(out, defaultResMap, defaultResMap);
}
private void dumpTexts(final PrintStream out) {
- final StringResourceMap defaultResMap = mResourcesMap.get(DEFAUT_LANGUAGE_NAME);
+ final StringResourceMap defaultResMap = mResourcesMap.get(DEFAULT_LANGUAGE_NAME);
final ArrayList<String> allLanguages = new ArrayList<String>();
allLanguages.addAll(mResourcesMap.keySet());
Collections.sort(allLanguages);
for (final String language : allLanguages) {
- if (language.equals(DEFAUT_LANGUAGE_NAME)) {
+ if (language.equals(DEFAULT_LANGUAGE_NAME)) {
continue;
}
out.format(" /* Language %s: %s */\n", language, getLanguageDisplayName(language));
@@ -174,17 +176,22 @@ public class MoreKeysResources {
allLanguages.addAll(mResourcesMap.keySet());
Collections.sort(allLanguages);
for (final String language : allLanguages) {
- out.format(" \"%s\", " + ARRAY_NAME_FOR_LANGUAGE + ", /* %s */\n",
- language, language, getLanguageDisplayName(language));
+ final Locale locale = LocaleUtils.constructLocaleFromString(language);
+ // If we use a different key, dump the original as comment for now.
+ final String languageKeyToDump = locale.getCountry().isEmpty()
+ ? String.format("\"%s\"", language)
+ : String.format("\"%s\" /* \"%s\" */", locale.getLanguage(), language);
+ out.format(" %s, " + ARRAY_NAME_FOR_LANGUAGE + ", /* %s */\n",
+ languageKeyToDump, language, getLanguageDisplayName(language));
}
}
private static String getLanguageDisplayName(final String language) {
- if (language.equals(NO_LANGUAGE_CODE)) {
+ final Locale locale = LocaleUtils.constructLocaleFromString(language);
+ if (locale.getLanguage().equals(NO_LANGUAGE_CODE)) {
return NO_LANGUAGE_DISPLAY_NAME;
- } else {
- return new Locale(language).getDisplayLanguage();
}
+ return locale.getDisplayName(Locale.ENGLISH);
}
private static void dumpTextsInternal(final PrintStream out, final StringResourceMap resMap,