diff options
Diffstat (limited to 'tools')
8 files changed, 28 insertions, 26 deletions
diff --git a/tools/dicttool/src/com/android/inputmethod/latin/dicttool/BinaryDictOffdeviceUtils.java b/tools/dicttool/src/com/android/inputmethod/latin/dicttool/BinaryDictOffdeviceUtils.java index 6c4cbcf9d..bd06e9f3a 100644 --- a/tools/dicttool/src/com/android/inputmethod/latin/dicttool/BinaryDictOffdeviceUtils.java +++ b/tools/dicttool/src/com/android/inputmethod/latin/dicttool/BinaryDictOffdeviceUtils.java @@ -80,17 +80,17 @@ public final class BinaryDictOffdeviceUtils { } /** - * Returns a decrypted/uncompressed binary dictionary. + * Returns a decrypted/uncompressed dictionary. * - * This will decrypt/uncompress any number of times as necessary until it finds the binary + * This will decrypt/uncompress any number of times as necessary until it finds the * dictionary signature, and copy the decoded file to a temporary place. - * If this is not a binary dictionary, the method returns null. + * If this is not a dictionary, the method returns null. */ - public static DecoderChainSpec getRawBinaryDictionaryOrNull(final File src) { - return getRawBinaryDictionaryOrNullInternal(new DecoderChainSpec(), src, 0); + public static DecoderChainSpec getRawDictionaryOrNull(final File src) { + return getRawDictionaryOrNullInternal(new DecoderChainSpec(), src, 0); } - private static DecoderChainSpec getRawBinaryDictionaryOrNullInternal( + private static DecoderChainSpec getRawDictionaryOrNullInternal( final DecoderChainSpec spec, final File src, final int depth) { // Unfortunately the decoding scheme we use can consider any data to be encrypted // and will product some output, meaning it's not possible to reliably detect encrypted @@ -98,7 +98,8 @@ public final class BinaryDictOffdeviceUtils { // over and over, ending in a stack overflow. Hence we limit the depth at which we try // decoding the file. if (depth > MAX_DECODE_DEPTH) return null; - if (BinaryDictDecoderUtils.isBinaryDictionary(src)) { + if (BinaryDictDecoderUtils.isBinaryDictionary(src) + || CombinedInputOutput.isCombinedDictionary(src.getAbsolutePath())) { spec.mFile = src; return spec; } @@ -106,7 +107,7 @@ public final class BinaryDictOffdeviceUtils { final File uncompressedFile = tryGetUncompressedFile(src); if (null != uncompressedFile) { final DecoderChainSpec newSpec = - getRawBinaryDictionaryOrNullInternal(spec, uncompressedFile, depth + 1); + getRawDictionaryOrNullInternal(spec, uncompressedFile, depth + 1); if (null == newSpec) return null; return newSpec.addStep(COMPRESSION); } @@ -114,7 +115,7 @@ public final class BinaryDictOffdeviceUtils { final File decryptedFile = tryGetDecryptedFile(src); if (null != decryptedFile) { final DecoderChainSpec newSpec = - getRawBinaryDictionaryOrNullInternal(spec, decryptedFile, depth + 1); + getRawDictionaryOrNullInternal(spec, decryptedFile, depth + 1); if (null == newSpec) return null; return newSpec.addStep(ENCRYPTION); } @@ -175,15 +176,16 @@ public final class BinaryDictOffdeviceUtils { return XmlDictInputOutput.readDictionaryXml( new BufferedInputStream(new FileInputStream(file)), null /* shortcuts */, null /* bigrams */); - } else if (CombinedInputOutput.isCombinedDictionary(filename)) { - if (report) System.out.println("Format : Combined format"); - return CombinedInputOutput.readDictionaryCombined( - new BufferedInputStream(new FileInputStream(file))); } else { - final DecoderChainSpec decodedSpec = getRawBinaryDictionaryOrNull(file); + final DecoderChainSpec decodedSpec = getRawDictionaryOrNull(file); if (null == decodedSpec) { crash(filename, new RuntimeException( filename + " does not seem to be a dictionary file")); + } else if (CombinedInputOutput.isCombinedDictionary( + decodedSpec.mFile.getAbsolutePath())){ + if (report) System.out.println("Format : Combined format"); + return CombinedInputOutput.readDictionaryCombined( + new BufferedInputStream(new FileInputStream(decodedSpec.mFile))); } else { final DictDecoder dictDecoder = FormatSpec.getDictDecoder(decodedSpec.mFile, DictDecoder.USE_BYTEARRAY); diff --git a/tools/dicttool/src/com/android/inputmethod/latin/dicttool/Package.java b/tools/dicttool/src/com/android/inputmethod/latin/dicttool/Package.java index 9274dcd2e..dff3387be 100644 --- a/tools/dicttool/src/com/android/inputmethod/latin/dicttool/Package.java +++ b/tools/dicttool/src/com/android/inputmethod/latin/dicttool/Package.java @@ -79,7 +79,7 @@ public class Package { throw new RuntimeException("Too many/too few arguments for command " + COMMAND); } final BinaryDictOffdeviceUtils.DecoderChainSpec decodedSpec = - BinaryDictOffdeviceUtils.getRawBinaryDictionaryOrNull(new File(mArgs[0])); + BinaryDictOffdeviceUtils.getRawDictionaryOrNull(new File(mArgs[0])); if (null == decodedSpec) { System.out.println(mArgs[0] + " does not seem to be a dictionary"); return; diff --git a/tools/dicttool/tests/com/android/inputmethod/latin/dicttool/BinaryDictOffdeviceUtilsTests.java b/tools/dicttool/tests/com/android/inputmethod/latin/dicttool/BinaryDictOffdeviceUtilsTests.java index 1eff497c1..1baeb7a47 100644 --- a/tools/dicttool/tests/com/android/inputmethod/latin/dicttool/BinaryDictOffdeviceUtilsTests.java +++ b/tools/dicttool/tests/com/android/inputmethod/latin/dicttool/BinaryDictOffdeviceUtilsTests.java @@ -64,7 +64,7 @@ public class BinaryDictOffdeviceUtilsTests extends TestCase { // Test for an actually compressed dictionary and its contents final BinaryDictOffdeviceUtils.DecoderChainSpec decodeSpec = - BinaryDictOffdeviceUtils.getRawBinaryDictionaryOrNull(dst); + BinaryDictOffdeviceUtils.getRawDictionaryOrNull(dst); for (final String step : decodeSpec.mDecoderSpec) { assertEquals("Wrong decode spec", BinaryDictOffdeviceUtils.COMPRESSION, step); } @@ -90,7 +90,7 @@ public class BinaryDictOffdeviceUtilsTests extends TestCase { // Test that a random data file actually fails assertNull("Wrongly identified data file", - BinaryDictOffdeviceUtils.getRawBinaryDictionaryOrNull(dst)); + BinaryDictOffdeviceUtils.getRawDictionaryOrNull(dst)); final File gzDst = File.createTempFile("testGetRawDict", ".tmp"); gzDst.deleteOnExit(); @@ -103,6 +103,6 @@ public class BinaryDictOffdeviceUtilsTests extends TestCase { // Test that a compressed random data file actually fails assertNull("Wrongly identified data file", - BinaryDictOffdeviceUtils.getRawBinaryDictionaryOrNull(gzDst)); + BinaryDictOffdeviceUtils.getRawDictionaryOrNull(gzDst)); } } 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 9728c9963..4cf742441 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 @@ -72,7 +72,7 @@ <string name="more_keys_for_l">l·l,ł</string> <!-- U+00B7: "·" MIDDLE DOT --> <string name="more_keys_for_punctuation">"!fixedColumnOrder!4,·,!,\\,,\?,:,;,\@"</string> - <string name="more_keys_for_tablet_period">\?,·</string> + <string name="more_keys_for_period">\?,·</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 849429629..8e6b4ee06 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 @@ -75,7 +75,7 @@ <!-- U+00A1: "¡" INVERTED EXCLAMATION MARK --> <string name="more_keys_for_tablet_comma">"!,¡"</string> <!-- U+00BF: "¿" INVERTED QUESTION MARK --> - <string name="more_keys_for_tablet_period">"\?,¿"</string> + <string name="more_keys_for_period">"\?,¿"</string> <string name="keylabel_for_apostrophe">\"</string> <string name="keyhintlabel_for_apostrophe">\'</string> <string name="more_keys_for_apostrophe">\'</string> 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 5a03c803c..ab4fbda44 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 @@ -81,8 +81,8 @@ <string name="keylabel_for_tablet_comma">"،"</string> <string name="keyhintlabel_for_tablet_comma">"!"</string> <string name="more_keys_for_tablet_comma">"!,\\,"</string> - <string name="keyhintlabel_for_tablet_period">"؟"</string> - <string name="more_keys_for_tablet_period">"؟,\?"</string> + <string name="keyhintlabel_for_period">"؟"</string> + <string name="more_keys_for_period">"؟,\?"</string> <string name="keylabel_for_apostrophe">،</string> <string name="keyhintlabel_for_apostrophe">؟</string> <string name="more_keys_for_apostrophe">"!fixedColumnOrder!4,:,!,؟,؛,-,/,«|»,»|«"</string> diff --git a/tools/make-keyboard-text/res/values-iw/donottranslate-more-keys.xml b/tools/make-keyboard-text/res/values-iw/donottranslate-more-keys.xml index feaed4c98..a1633316f 100644 --- a/tools/make-keyboard-text/res/values-iw/donottranslate-more-keys.xml +++ b/tools/make-keyboard-text/res/values-iw/donottranslate-more-keys.xml @@ -55,6 +55,6 @@ <string name="keylabel_for_currency">₪</string> <string name="keyhintlabel_for_tablet_comma">!</string> <string name="more_keys_for_tablet_comma">!</string> - <string name="keyhintlabel_for_tablet_period">\?</string> - <string name="more_keys_for_tablet_period">\?</string> + <string name="keyhintlabel_for_period">\?</string> + <string name="more_keys_for_period">\?</string> </resources> 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 cc09f7fe5..44aa64cbe 100644 --- a/tools/make-keyboard-text/res/values/donottranslate-more-keys.xml +++ b/tools/make-keyboard-text/res/values/donottranslate-more-keys.xml @@ -169,9 +169,9 @@ <string name="keylabel_for_tablet_comma">,</string> <string name="keyhintlabel_for_tablet_comma"></string> <string name="more_keys_for_tablet_comma"></string> - <string name="keyhintlabel_for_tablet_period"></string> + <string name="keyhintlabel_for_period"></string> <!-- U+2026: "…" HORIZONTAL ELLIPSIS --> - <string name="more_keys_for_tablet_period">…</string> + <string name="more_keys_for_period">…</string> <string name="keylabel_for_apostrophe">\'</string> <string name="keyhintlabel_for_apostrophe">\"</string> <string name="more_keys_for_apostrophe">\"</string> |