Interpret Latin input as both Romaji and English fixes-2021
authorMax Staudt <max@enpas.org>
Tue, 28 Dec 2021 02:21:47 +0000 (03:21 +0100)
committernorly <ny-git@enpas.org>
Tue, 28 Dec 2021 02:38:20 +0000 (03:38 +0100)
This allows jmdict to be fed any input and autodetecting the intended
translation direction, similar to Sumatora on Android.

Whether English, Romaji, Kana, or Kanji - it will simply do The Right
Thing To Do(TM):

  UTF8 input -> Japanese->English
  Non-UTF8 input -> Romaji->English, plus English->Japanese

jmdict.cpp

index efbb7057db281569907c3c2831d56ae1a253b51a..2364ab5cea0512d4da040193dbfeb22052df0675 100644 (file)
@@ -161,7 +161,8 @@ void guessLanguage(const std::string& subject) {
     if (options::source == options::JAPANESE && !isUTF8)
         options::source = options::JAPANESE_ROMAJI;
     else if (options::source == options::UNKNOWN)
-        options::source = isUTF8 ? options::JAPANESE : options::NOT_JAPANESE;
+    //    options::source = isUTF8 ? options::JAPANESE : options::NOT_JAPANESE;
+        options::source = isUTF8 ? options::JAPANESE : options::UNKNOWN;
 }
 
 int main(int argc, char** argv)
@@ -180,8 +181,12 @@ try {
         fromJapanese(subject);
     else if (options::source == options::JAPANESE_ROMAJI)
         fromRomaji(subject);
-    else
+    else if (options::source == options::NOT_JAPANESE)
+        toJapanese(subject);
+    else {
+        fromRomaji(subject);
         toJapanese(subject);
+    }
     cout << entries << " match(es) found." << endl;
 
     return EXIT_SUCCESS;