polish aux text
authorPeng Wu <alexepico@gmail.com>
Thu, 2 Aug 2012 03:24:39 +0000 (11:24 +0800)
committerPeng Wu <alexepico@gmail.com>
Thu, 2 Aug 2012 07:49:29 +0000 (15:49 +0800)
src/PYEnglishEditor.cc
src/PYEnglishEditor.h
src/PYStrokeEditor.cc
src/PYStrokeEditor.h

index 2e9a37c..333ea96 100644 (file)
 #include <string>
 #include <vector>
 #include <stdio.h>
+#include <libintl.h>
 #include <sqlite3.h>
 #include <glib.h>
 #include <glib/gstdio.h>
 #include "PYConfig.h"
 #include "PYString.h"
 
+#define _(text) (gettext(text))
 
 namespace PY {
 
@@ -181,7 +183,7 @@ public:
         const char *SQL_DB_LIST = 
             "SELECT word FROM ( "
             "SELECT * FROM english UNION ALL SELECT * FROM userdb.english) "
-            " WHERE word LIKE '%s%' GROUP BY word ORDER BY SUM(freq) DESC;";
+            " WHERE word LIKE \"%s%\" GROUP BY word ORDER BY SUM(freq) DESC;";
         m_sql.printf (SQL_DB_LIST, prefix);
         int result = sqlite3_prepare_v2 (m_sqlite, m_sql.c_str(), -1, &stmt, &tail);
         if (result != SQLITE_OK)
@@ -605,6 +607,13 @@ EnglishEditor::updateStateFromInput (void)
     m_auxiliary_text = "v";
     if (1 == m_text.length ()) {
         clearLookupTable ();
+
+        const char * help_string = _("Please input the english word.");
+        int space_len = std::max ( 0, m_aux_text_len
+                                   - (int) g_utf8_strlen (help_string, -1));
+        m_auxiliary_text.append (space_len, ' ');
+        m_auxiliary_text += help_string;
+
         return TRUE;
     }
 
index 2232544..68d5e1d 100644 (file)
@@ -76,6 +76,8 @@ private:
     String m_auxiliary_text;
 
     EnglishDatabase *m_english_database;
+
+    const static int m_aux_text_len = 50;
 };
 
 };
index b2dfe22..252dddd 100644 (file)
 #include <string.h>
 #include <string>
 #include <vector>
+#include <libintl.h>
 #include <glib.h>
 #include <sqlite3.h>
 #include "PYString.h"
 #include "PYConfig.h"
 
+#define _(text) (gettext (text))
+
 namespace PY {
+
 class StrokeDatabase{
 public:
     StrokeDatabase(){
@@ -378,6 +382,14 @@ StrokeEditor::updateStateFromInput (void)
     m_auxiliary_text = "u";
     if (1 == m_text.length ()) {
         clearLookupTable ();
+
+        const char * help_string =
+            _("Please use \"hspnz\" to input.");
+        int space_len = std::max ( 0, m_aux_text_len
+                                   - (int) g_utf8_strlen (help_string, -1));
+        m_auxiliary_text.append(space_len, ' ');
+        m_auxiliary_text += help_string;
+
         return TRUE;
     }
 
index 7f9b4ab..4048948 100644 (file)
@@ -72,6 +72,8 @@ private:
     String m_auxiliary_text;
 
     StrokeDatabase *m_stroke_database;
+
+    const static int m_aux_text_len = 50;
 };
 
 };