From a0f08df51e094e43635805ab36c75c7d812e0ce9 Mon Sep 17 00:00:00 2001 From: srowen Date: Sat, 17 Sep 2011 16:23:36 +0000 Subject: [PATCH] Japanese language strings better as "values-ja", and other small translator tweaks git-svn-id: https://zxing.googlecode.com/svn/trunk@1914 59b500cc-1b3d-0410-9834-0bbf25fbcc57 --- .../res/{values-ja-rJP => values-ja}/strings.xml | 0 .../zxing/client/android/LocaleManager.java | 16 +++++++++------- .../google/zxing/StringsResourceTranslator.java | 6 +++--- 3 files changed, 12 insertions(+), 10 deletions(-) rename android/res/{values-ja-rJP => values-ja}/strings.xml (100%) diff --git a/android/res/values-ja-rJP/strings.xml b/android/res/values-ja/strings.xml similarity index 100% rename from android/res/values-ja-rJP/strings.xml rename to android/res/values-ja/strings.xml diff --git a/android/src/com/google/zxing/client/android/LocaleManager.java b/android/src/com/google/zxing/client/android/LocaleManager.java index b829ea10a..c7edbef88 100644 --- a/android/src/com/google/zxing/client/android/LocaleManager.java +++ b/android/src/com/google/zxing/client/android/LocaleManager.java @@ -16,8 +16,8 @@ package com.google.zxing.client.android; +import java.util.Arrays; import java.util.Collection; -import java.util.HashSet; import java.util.Locale; import java.util.Map; import java.util.HashMap; @@ -38,7 +38,12 @@ public final class LocaleManager { static { Locale locale = Locale.getDefault(); COUNTRY = locale == null ? DEFAULT_COUNTRY : locale.getCountry(); - LANGUAGE = locale == null ? DEFAULT_LANGUAGE : locale.getLanguage(); + String language = locale == null ? DEFAULT_LANGUAGE : locale.getLanguage(); + // Special case Chinese + if (Locale.SIMPLIFIED_CHINESE.getLanguage().equals(language)) { + language += "-r" + COUNTRY; + } + LANGUAGE = language; } /** @@ -104,11 +109,8 @@ public final class LocaleManager { */ private static final Map GOOGLE_BOOK_SEARCH_COUNTRY_TLD = GOOGLE_COUNTRY_TLD; - private static final Collection TRANSLATED_HELP_ASSET_LANGUAGES; - static { - TRANSLATED_HELP_ASSET_LANGUAGES = new HashSet(); - TRANSLATED_HELP_ASSET_LANGUAGES.add("en"); - } + private static final Collection TRANSLATED_HELP_ASSET_LANGUAGES = + Arrays.asList("en"); private LocaleManager() {} diff --git a/javase/src/com/google/zxing/StringsResourceTranslator.java b/javase/src/com/google/zxing/StringsResourceTranslator.java index 9440f7e51..db7af5e2e 100644 --- a/javase/src/com/google/zxing/StringsResourceTranslator.java +++ b/javase/src/com/google/zxing/StringsResourceTranslator.java @@ -51,7 +51,7 @@ import java.util.regex.Pattern; */ public final class StringsResourceTranslator { - private static final long MIN_API_CALL_INTERVAL_MS = 5 * 1000L; + private static final long MIN_API_CALL_INTERVAL_MS = 10 * 1000L; private static final Charset UTF8 = Charset.forName("UTF-8"); private static final Pattern ENTRY_PATTERN = Pattern.compile("([^<]+)"); @@ -76,9 +76,8 @@ public final class StringsResourceTranslator { " limitations under the License.\n" + " -->\n"; - private static final Map LANGUAGE_CODE_MASSAGINGS = new HashMap(7); + private static final Map LANGUAGE_CODE_MASSAGINGS = new HashMap(3); static { - LANGUAGE_CODE_MASSAGINGS.put("ja-rJP", "ja"); LANGUAGE_CODE_MASSAGINGS.put("zh-rCN", "zh-cn"); LANGUAGE_CODE_MASSAGINGS.put("zh-rTW", "zh-tw"); } @@ -216,6 +215,7 @@ public final class StringsResourceTranslator { // This is a little crude; unescape some common escapes in the raw response translation = translation.replaceAll("\\\\u0026quot;", "\""); translation = translation.replaceAll("\\\\u0026#39;", "'"); + translation = translation.replaceAll("\\\\u200b", ""); return translation; }