[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdesdk/kbabel
From:       Stanislav Višňovský <visnovsky () nenya ! ms ! mff ! cuni ! cz
Date:       2004-11-18 18:10:45
Message-ID: 20041118181045.F170816E5D () office ! kde ! org
[Download RAW message or body]

CVS commit by nanulo: 

Implemented word count


  M +2 -2      catalogmanager/catalogmanagerview.cpp   1.100
  M +31 -0     common/catalog.cpp   1.130
  M +3 -0      common/catalog.h   1.60
  M +2 -1      filters/Makefile.am   1.3
  M +2 -0      kbabel/kbabel.cpp   1.191
  M +3 -1      kbabel/kbabelui.rc   1.47
  M +1 -0      kbabel/kbabelview.h   1.106
  M +12 -0     kbabel/kbabelview2.cpp   1.78


--- kdesdk/kbabel/catalogmanager/catalogmanagerview.cpp  #1.99:1.100
@@ -1585,5 +1585,5 @@ void CatalogManagerView::buildTree()
       KMessageBox::error(this,i18n("You have not specified a valid folder "
 "for the base folder of the PO files:\n%1\n"
-"Please check your settings in the preferences dialog!").arg(_settings.poBaseDir));
+"Please check your settings in the project settings \
dialog!").arg(_settings.poBaseDir));  
       _active=false;
@@ -1601,5 +1601,5 @@ void CatalogManagerView::buildTree()
       KMessageBox::error(this,i18n("You have not specified a valid folder "
 "for the base folder of the PO template files:\n%1\n"
-"Please check your settings in the preferences dialog!").arg(_settings.potBaseDir));
+"Please check your settings in the project settings \
dialog!").arg(_settings.potBaseDir));  }
 

--- kdesdk/kbabel/common/catalog.cpp  #1.129:1.130
@@ -3528,3 +3528,34 @@ QString Catalog::mimeTypes() const
 }
 
+void Catalog::wordCount (uint &total, uint &fuzzy, uint &untranslated) const
+{
+    total = 0;
+    fuzzy = 0;
+    untranslated = 0;
+    
+    QRegExp separator( "[ \n\t]+" );
+    
+    for ( QValueVector<CatalogItem>::Iterator it = d->_entries.begin();
+                                        it != d->_entries.end(); ++it)
+    {
+        // find out the number of words for this message
+        
+        // join all forms together
+        QString message = (*it).msgid ().join (" ");
+        
+        // remove tags first
+        d->_tagExtractor->setString( message );
+        message = d->_tagExtractor->plainString(false);
+
+        QStringList words = QStringList::split ( separator, message );
+        
+        total += words.count();
+
+        if ( (*it).isFuzzy() )
+            fuzzy += words.count();
+        else if ( (*it).isUntranslated() )
+            untranslated += words.count();
+    }    
+}
+
 #include "catalog.moc"

--- kdesdk/kbabel/common/catalog.h  #1.59:1.60
@@ -369,4 +369,7 @@ public:
    uint numberOfUntranslated() const;
 
+   /** returns the number of words total, in fuzzy and in untranslated messages */
+   void wordCount (uint &total, uint &fuzzy, uint &untranslated) const;
+
    bool hasFuzzyInFront(uint index) const;
    bool hasFuzzyAfterwards(uint index) const;

--- kdesdk/kbabel/filters/Makefile.am  #1.2:1.3
@@ -1,2 +1,3 @@
-SUBDIRS = gettext linguist
+SUBDIRS = gettext linguist xliff
+
 

--- kdesdk/kbabel/kbabel/kbabel.cpp  #1.190:1.191
@@ -626,4 +626,6 @@ void KBabelMW::setupActions()
    new KAction( i18n("Toggle Edit Mode"), 0, Key_Insert,this,SLOT(toggleEditMode()), \
actionCollection(), "toggle_insert_mode");  
+   new KAction( i18n("&Word Count"), 0, m_view, SLOT(wordCount()), \
actionCollection(), "word_count");    +
     // next, the settings menu
     createStandardStatusBarAction();

--- kdesdk/kbabel/kbabel/kbabelui.rc  #1.46:1.47
@@ -1,4 +1,4 @@
 <!DOCTYPE kpartgui>
-<kpartgui name="kbabel" version="20">
+<kpartgui name="kbabel" version="21">
  <MenuBar>
    <Menu name="file"><text>&amp;File</text>
@@ -75,4 +75,5 @@
     <Separator/>
     <Action name="rough_translation"/>
+    <Action name="word_count"/>
     <Separator/>
     <Action name="open_catalog_manager"/>
@@ -228,4 +229,5 @@
     <Action name="dynamic_modify_tools"/>
     <Action name="add_bookmark"/>
+    <Action name="word_found"/>
     </Enable>
  </State>

--- kdesdk/kbabel/kbabel/kbabelview.h  #1.105:1.106
@@ -254,4 +254,5 @@ public slots:
     void skipToPreviousTag();
     void skipToTagFromTool(int index);
+    void wordCount();
 
     void removeFuzzyStatus();

--- kdesdk/kbabel/kbabel/kbabelview2.cpp  #1.77:1.78
@@ -997,2 +997,14 @@ void KBabelView::insertChar( QChar ch )
 }
 
+void KBabelView::wordCount()
+{
+    uint total, untranslated, fuzzy;
+    
+    _catalog->wordCount( total, fuzzy, untranslated );
+    
+    KMessageBox::information( this
+        , i18n("Total words: %1\n\n"
+"Words in untranslated messages: %2\n\n"
+"Words in fuzzy messages: %3").arg(total).arg(untranslated).arg(fuzzy)
+        , i18n("Word Count") );
+}


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic