add stardict plugin translations
[mdictionary] / src / plugins / stardict / StarDictPlugin.cpp
index 227cc25..aa055e4 100644 (file)
@@ -50,8 +50,8 @@ void StarDictPlugin::retranslate() {
 
     QTranslator *translator = new QTranslator(this);
 
-    if(!translator->load(":/xdxf/translations/" + locale)) {
-        translator->load(":/xdxf/translations/en_US");
+    if(!translator->load(":/stardict/translations/" + locale)) {
+        translator->load(":/stardict/translations/en_US");
     }
     QCoreApplication::installTranslator(translator);
 }
@@ -109,7 +109,8 @@ QList<Translation*> StarDictPlugin::searchWordList(QString word, int limit) {
 
     int counter = 0;
     int counterLimit = 0;
-    while(counter < wordcount && (counterLimit<limit || limit==0)) {
+    stopped=false;
+    while(counter < wordcount && (counterLimit<limit || limit==0) && !stopped) {
         counter++;
         fkey = reader->readKeyword();
         if(is32b)
@@ -161,6 +162,7 @@ QByteArray StarDictPlugin::read(QByteArray::iterator it,
 QString StarDictPlugin::interpret(QByteArray::iterator it,
         QByteArray::iterator end, QChar mode,QString key, bool last) {
     QString result;
+    qDebug()<<"****** mode:     "<<mode;
     if(mode == 'm'){
         result += "<key>" + key + "</key>";
         result += QString::fromUtf8(read(it++, end));
@@ -172,6 +174,15 @@ QString StarDictPlugin::interpret(QByteArray::iterator it,
     else if(mode ==  'g'){
         result += "<key>" + key + "</key>";
         result += QString::fromUtf8(read(it++, end));
+
+        /* delete "small" tag  from translation*/
+        int indexOfSmall=result.indexOf("<small>");
+        while(indexOfSmall!=-1){
+            int indexOfEndSmall= result.indexOf("</small>");
+            if(indexOfEndSmall!=-1)
+                result.remove(indexOfSmall,indexOfEndSmall-indexOfSmall+8);
+            indexOfSmall=result.indexOf("<small>");
+        }
     }
     else if(mode == 't'){
         result += "<key>" + key + "</key>";
@@ -206,7 +217,7 @@ QString StarDictPlugin::interpret(QByteArray::iterator it,
     else if(mode == 'r'){
         result += "<key>" + key + "</key>";
         result += QString::fromUtf8(read(it++, end));
-        }
+    }
 
 // Dont know whether mDictionary would ever handle binary stardict format
 //     to be honest dont see any kind of adventages (can't find any binary dict)
@@ -235,6 +246,8 @@ QString StarDictPlugin::interpret(QByteArray::iterator it,
         } else
             result += read(it++, end);
     } */
+
+    qDebug()<<"wynik  "<<result;
     return result;
 }
 
@@ -270,6 +283,7 @@ QString StarDictPlugin::search(QString key, qint64 offset, qint32 len) {
 
 
 void StarDictPlugin::stop() {
+    qDebug()<<"zatrzymanie programu";
     stopped=true;
 }
 
@@ -288,10 +302,7 @@ CommonDictInterface* StarDictPlugin::getNew(const Settings *settings) const {
     ((StarDictDialog*)plugin->dictDialog())->
             setLastDialogParent(_dictDialog->lastDialogParent());
 
-
-
     if(settings && plugin->setSettings(settings)) {
-
         disconnect(plugin, SIGNAL(notify(Notify::NotifyType,QString)),
                 this, SIGNAL(notify(Notify::NotifyType,QString)));
         plugin->getDictionaryInfo();