summaryrefslogtreecommitdiffstats
path: root/kbabel/datatools/whitespace
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commitbd9e6617827818fd043452c08c606f07b78014a0 (patch)
tree425bb4c3168f9c02f10150f235d2cb998dcc6108 /kbabel/datatools/whitespace
downloadtdesdk-bd9e6617827818fd043452c08c606f07b78014a0.tar.gz
tdesdk-bd9e6617827818fd043452c08c606f07b78014a0.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdesdk@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kbabel/datatools/whitespace')
-rw-r--r--kbabel/datatools/whitespace/Makefile.am19
-rw-r--r--kbabel/datatools/whitespace/kbabel_whitespacetool.desktop98
-rw-r--r--kbabel/datatools/whitespace/main.cc144
-rw-r--r--kbabel/datatools/whitespace/main.h55
-rw-r--r--kbabel/datatools/whitespace/test.po92
5 files changed, 408 insertions, 0 deletions
diff --git a/kbabel/datatools/whitespace/Makefile.am b/kbabel/datatools/whitespace/Makefile.am
new file mode 100644
index 00000000..f0987b4f
--- /dev/null
+++ b/kbabel/datatools/whitespace/Makefile.am
@@ -0,0 +1,19 @@
+
+INCLUDES = -I$(srcdir)/../../common -I../../common $(all_includes)
+kbabel_whitespacetool_la_LIBADD = $(LIB_KIO) ../../common/libkbabelcommon.la
+
+####### Files
+
+kde_module_LTLIBRARIES = kbabel_whitespacetool.la
+
+kbabel_whitespacetool_la_SOURCES = main.cc
+
+kbabel_whitespacetool_la_LDFLAGS = $(all_libraries) -avoid-version -module -no-undefined
+
+noinst_HEADERS = main.h
+
+kbabel_whitespacetool_la_METASOURCES = AUTO
+
+service_DATA = kbabel_whitespacetool.desktop
+servicedir = $(kde_servicesdir)
+
diff --git a/kbabel/datatools/whitespace/kbabel_whitespacetool.desktop b/kbabel/datatools/whitespace/kbabel_whitespacetool.desktop
new file mode 100644
index 00000000..74de2bc4
--- /dev/null
+++ b/kbabel/datatools/whitespace/kbabel_whitespacetool.desktop
@@ -0,0 +1,98 @@
+[Desktop Entry]
+Name=String Translated as Whitespace Validator for KBabel
+Name[bg]=Валидност на низовете, преведени като интервали - KBabel
+Name[bs]=Provjera stringova prevedenih kao blanko znaci za KBabel
+Name[ca]=Validació de cadenes traduïdes com un espai en blanc per a KBabel
+Name[cs]=Validátor překladů bílých mezer
+Name[cy]=Dilysydd Llinyn wedi'i Gyfieithu fel Gofodnod ar gyfer KBabel
+Name[da]=Streng oversat som blanke tegn-validering for KBabel
+Name[de]=Prüfung auf Leerzeichenübersetzungen für KBabel
+Name[el]=Ελεγκτής εγκυρότητας συμβολοσειρών μεταφρασμένα ως κενό για το KBabel
+Name[es]=Validador de cadenas traducidas como espacios en blanco.para KBabel
+Name[et]=KBabeli tühimärgiks tõlgitud teadete kontrollija
+Name[eu]=Zurigune bezala itzulitako kateen balidatzailea KBabel-entzat
+Name[fa]=رشتۀ ترجمه‌شده به عنوان اعتبارسنج فاصلۀ سفید برای KBabel
+Name[fi]=Tyhjeinä käännettyjen merkkijonojen tarkistaja KBabelissa
+Name[fr]=Validateur de chaînes traduites comme des espaces pour KBabel
+Name[gl]=Validación de texto traducido como espazo para KBabel
+Name[hu]=Csak üres karaktereket tartalmazó fordítások kiszűrése a KBabelben
+Name[is]=Staðfestir fyrir KBabel fyrir strengi þýdda sem bil
+Name[it]=Convalidatore delle stringhe tradotte con spazi bianchi per KBabel
+Name[ja]=KBabel 空白として翻訳された文字列を検索
+Name[ka]=სტრიქონი ნათარგმნია როგორც Whitespace დამმოწმებელი KBabel-სთვის
+Name[kk]=KBabel-дың бос орын аудармаларын тексеруі
+Name[lt]=KBabel eilučių, išverstų tuščiais tarpais, patikros įrankis
+Name[nb]=Se etter tomme strenger i KBabel
+Name[nds]=Leertekenöversetten-Prööv för KBabel
+Name[ne]=क्याबेलका लागि सेतो रिक्तस्थान प्रमाणीतकर्ता अनुरुप अनुबाद गरिएका स्ट्रिङ
+Name[nl]=Tekst-vertaald-als-witruimte-validatie voor KBabel
+Name[nn]=Sjå etter tomme strengar i KBabel
+Name[pl]=Sprawdzenie czy napis jest przetłumaczony jako białe znaki w KBabel
+Name[pt]=Validação de Texto Traduzido como Espaço para o KBabel
+Name[pt_BR]=Validador de String Traduzidos com Espaços em Branco para o KBabel
+Name[ru]=Проверка строк, переведённых как пробел для KBabel
+Name[sk]=Kontrola textu preloženého ako prázdny pre KBabel
+Name[sl]=Potrjevalnik nizov, prevedenih kot presledki, za KBabel
+Name[sr]=Оверивач за низове знакова преведене као празан простор за KBabel
+Name[sr@Latn]=Overivač za nizove znakova prevedene kao prazan prostor za KBabel
+Name[sv]=Validering av sträng översatt som blanktecken för Kbabel
+Name[ta]=Kபாபேலுக்கு சரம் மொழிபெயர்ப்பு இடைவேலை மதிப்பீட்டாளர்
+Name[tg]=Тафтиши сатр, ки мисли фосила барои KBabel, тарҷума шудааст
+Name[tr]=KBabel için Ayırma Boşluğu gibi Çevrilen Dizge Denetimi
+Name[uk]=Перевірка фраз, перекладених як пропуски, для KBabel
+Name[zh_CN]=KBabel 的字符串译为空格的检查器
+Name[zh_TW]=KBabel 翻譯為空白字串檢查器
+ValidationString=whitespace checking
+X-KDE-Library=kbabel_whitespacetool
+Type=Service
+Commands=validate
+Comment=Whitespace Translations
+Comment[bg]=Низове, преведени като интервали
+Comment[bs]=Blanko prijevodi
+Comment[ca]=Traduccions amb espai en blanc
+Comment[cs]=Překlady mezer
+Comment[cy]=Cyfieithiadau Gofodnod
+Comment[da]=Oversatte blanke tegn
+Comment[de]=Leerzeichen-Übersetzungen
+Comment[el]=Μεταφράσεις με κενό
+Comment[es]=Traducciones de espacios en blanco
+Comment[et]=Tühimärkidest koosnevad tõlked
+Comment[eu]=Zurigune itzulpenak
+Comment[fa]=ترجمۀ فاصله‌های سفید
+Comment[fi]=Tyhjeiden käännökset
+Comment[fr]=Traductions en espaces
+Comment[gl]=Traducións de espazos en branco
+Comment[he]=תרגומים של תווים נקיים
+Comment[hi]=व्हाइट-स्पेस अनुवाद
+Comment[hu]=Az üres fordítások kiszűrése
+Comment[is]=Þýðingar bila
+Comment[it]=Traduzioni con spazi bianchi
+Comment[ja]=空白翻訳文字列を検索
+Comment[ka]=Whitespace მთარგმნელები
+Comment[kk]=Бос орын аудармалары
+Comment[lt]=Tuščių eilučių patikra
+Comment[ms]=Terjemahan Ruang Kosong
+Comment[nb]=Tomme strenger
+Comment[nds]=Leertekenöversetten pröven
+Comment[ne]=सेतो रिक्तस्थान अनुबाद
+Comment[nl]=Lege vertalingen
+Comment[nn]=Tomme strengar
+Comment[pl]=Tłumaczenia w postaci białych znaków
+Comment[pt]=Traduções de Espaços em Branco
+Comment[pt_BR]=Traduções com espaços em branco
+Comment[ru]=Пустые переводы
+Comment[sk]=Prázdne preklady
+Comment[sl]=Prevodi presledkov
+Comment[sr]=Преводи као празан простор
+Comment[sr@Latn]=Prevodi kao prazan prostor
+Comment[sv]=Översättning med blanktecken
+Comment[ta]= இடைவேலை பெயர்ப்பு
+Comment[tg]=Тарҷумаҳои холӣ
+Comment[tr]=Ayırma Boşluğu Çevirileri
+Comment[uk]=Порожні переклади
+Comment[zh_CN]=空白翻译
+Comment[zh_TW]=空白翻譯
+ServiceTypes=KDataTool,KBabelValidator
+DataType=CatalogItem
+DataMimeTypes=application/x-kbabel-catalogitem
+ReadOnly=true
diff --git a/kbabel/datatools/whitespace/main.cc b/kbabel/datatools/whitespace/main.cc
new file mode 100644
index 00000000..9987c465
--- /dev/null
+++ b/kbabel/datatools/whitespace/main.cc
@@ -0,0 +1,144 @@
+/* This file is part of KBabel
+ based Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
+ 2002 Stanislav Visnovsky <visnovsky@kde.org>
+ 2003 Dwayne Bailey <dwayne@translate.org.za>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+ In addition, as a special exception, the copyright holders give
+ permission to link the code of this program with any edition of
+ the Qt library by Trolltech AS, Norway (or with modified versions
+ of Qt that use the same license as Qt), and distribute linked
+ combinations including the two. You must obey the GNU General
+ Public License in all respects for all of the code used other than
+ Qt. If you modify this file, you may extend this exception to
+ your version of the file, but you are not obligated to do so. If
+ you do not wish to do so, delete this exception statement from
+ your version.
+
+*/
+
+#include <resources.h>
+#include "catalog.h"
+#include "catalogitem.h"
+#include "catalogsettings.h"
+#include "main.h"
+
+#include <kconfig.h>
+#include <kdebug.h>
+#include <kgenericfactory.h>
+#include <klibloader.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+
+/***************************************************
+ *
+ * Factory
+ *
+ ***************************************************/
+
+K_EXPORT_COMPONENT_FACTORY( kbabel_whitespacetool, KGenericFactory<WhitespaceTool> ( "kbabeldatatool" ) )
+
+using namespace KBabel;
+
+WhitespaceTool::WhitespaceTool( QObject* parent, const char* name, const QStringList & )
+ : KDataTool( parent, name ), _cache_origin( 0 ), _equation("^[a-zA-Z0-9]+=")
+{
+ i18n("which check found errors","whitespace only translation");
+}
+
+bool WhitespaceTool::run( const QString& command, void* data, const QString& datatype, const QString& mimetype )
+{
+
+ if ( command != "validate" )
+ {
+ kdDebug(KBABEL) << "Whitespace Tool only accepts the 'validate' command" << endl;
+ kdDebug(KBABEL) << " The command " << command << " is not accepted" << endl;
+ return false;
+ }
+
+ // Check wether we can accept the data
+ if ( datatype != "CatalogItem" )
+ {
+ kdDebug(KBABEL) << "Whitespace Tool only accept the CatalogItem datatype" << endl;
+ return false;
+ }
+
+ if ( mimetype != "application/x-kbabel-catalogitem" )
+ {
+ kdDebug(KBABEL) << "Whitespace Tool only accept the 'application/x-kbabel-catalogitem' mimetype" << endl;
+ return false;
+ }
+
+ if( command == "validate" )
+ {
+
+ CatalogItem* item = (CatalogItem*)(data);
+ bool hasIdError = false;
+ bool hasStrError = false;
+ QRegExp _whitespace("^\\s+$");
+ QStringList str, id;
+
+ if(!item->isUntranslated()) {
+ if( _cache_origin != item->project() )
+ {
+ _plurals = item->project()->miscSettings().singularPlural;
+ _cache_origin = item->project();
+ }
+
+ //Ensure KDE plural forms are in a StringList
+ //FIXME Eliminate context information and this could become a generic message splitter
+ if( item->pluralForm() == KDESpecific ) {
+ str = QStringList::split( "\\n", item->msgstr().first(), true );
+ id = QStringList::split( "\\n",
+ item->msgid().first().replace( QRegExp(_plurals), ""), true );
+ } else {
+ str = item->msgstr();
+ id = item->msgid();
+ }
+
+ //Strip equations
+ id.first().replace( QRegExp(_equation), "");
+ str.first().replace( QRegExp(_equation), "");
+
+ //Ignore Messages with blank msgid components
+ for( QStringList::Iterator it = id.begin() ; it != id.end() ; it++ ) {
+ QString resultstring = (*it);
+ hasIdError = hasIdError || resultstring.contains(_whitespace);
+ }
+ if( hasIdError ) return true;
+
+ //Check each QString in the List is not whitespace
+ for( QStringList::Iterator it = str.begin() ; it != str.end() ; it++ ) {
+ QString resultstring = (*it);
+ hasStrError = hasStrError || resultstring.contains(_whitespace);
+ }
+
+ }
+
+ if(hasStrError) {
+ item->appendError( "whitespace translation" );
+ return false;
+ } else {
+ item->removeError( "whitespace translation" );
+ return true;
+ }
+
+ }
+ return false;
+}
+
+#include "main.moc"
diff --git a/kbabel/datatools/whitespace/main.h b/kbabel/datatools/whitespace/main.h
new file mode 100644
index 00000000..9a0545cc
--- /dev/null
+++ b/kbabel/datatools/whitespace/main.h
@@ -0,0 +1,55 @@
+/* This file is part of KBabel
+ based on Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
+ 2002 Stanislav Visnovsky <visnovsky@kde.org>
+ 2003 Dwayne Bailey <dwayne@translate.org.za>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+ In addition, as a special exception, the copyright holders give
+ permission to link the code of this program with any edition of
+ the Qt library by Trolltech AS, Norway (or with modified versions
+ of Qt that use the same license as Qt), and distribute linked
+ combinations including the two. You must obey the GNU General
+ Public License in all respects for all of the code used other than
+ Qt. If you modify this file, you may extend this exception to
+ your version of the file, but you are not obligated to do so. If
+ you do not wish to do so, delete this exception statement from
+ your version.
+
+*/
+
+#ifndef __main_h__
+#define __main_h__
+
+#include "kbproject.h"
+
+#include <qregexp.h>
+#include <kdatatool.h>
+
+class WhitespaceTool : public KDataTool
+{
+ Q_OBJECT
+
+public:
+ WhitespaceTool( QObject* parent, const char* name, const QStringList & );
+ virtual bool run( const QString& command, void* data, const QString& datatype, const QString& mimetype);
+private:
+ KBabel::Project::Ptr _cache_origin;
+ QRegExp _plurals;
+ QRegExp _equation;
+};
+
+#endif
diff --git a/kbabel/datatools/whitespace/test.po b/kbabel/datatools/whitespace/test.po
new file mode 100644
index 00000000..96fb59d7
--- /dev/null
+++ b/kbabel/datatools/whitespace/test.po
@@ -0,0 +1,92 @@
+# Test file to validate the whitespace checking tool
+# Dwayne Bailey <dwayne@translate.org.za>, 2003
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: test\n"
+"Last-Translator: Dwayne Bailey <dwayne@translate.org.za>\n"
+"PO-Revision-Date: 2003-01-09 09:35+0200\n"
+"Language-Team: <english@translate.org.za>\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Generator: KBabel 1.2\n"
+
+# msgstr incorrectly translated with whitespace - 2*<sp>
+# Expected Result = error
+msgid "Some translation string"
+msgstr " "
+
+# msgid with 3*<sp> translated to 2*<sp> This should be valid
+# Expected Result = valid
+msgid " "
+msgstr " "
+
+# plural checks for KDE with a blank msgstr
+# Expected Result = error
+msgid ""
+"_n: Plural translation\n"
+"Second form %n"
+msgstr ""
+"First fine second wrong\n"
+" "
+
+# plural checks for KDE with everything correct
+# Expected Result = valid
+msgid ""
+"_n: Plural translation\n"
+"Second form %n"
+msgstr ""
+"First fine\n"
+"Second fine"
+
+# plural checks for KDE with bad msgid
+# Expected Result = valid
+msgid ""
+"_n: \n"
+"First form missing"
+msgstr ""
+"\n"
+"Second fine"
+
+# plural checks for KDE with bad msgid
+# Expected Result = valid
+msgid ""
+"_n: Second is missing\n"
+""
+msgstr ""
+"First fine\n"
+""
+
+# Plural check on GNU format with a missing plural
+# Expected Result = error
+msgid "Plural translation"
+msgid_plural "The second form %n"
+msgstr[0] "First fine second wrong"
+msgstr[1] " "
+
+# Plural check on GNU format in order
+# Expected Result = valid
+msgid "Plural translation"
+msgid_plural "The second form %n"
+msgstr[0] "First fine"
+msgstr[1] "Second fine"
+
+# Plural check on GNU format with singular missing
+# Expected Result = valid
+msgid ""
+msgid_plural "Singluar is missing"
+msgstr[0] ""
+msgstr[1] "Plural was translated"
+
+# Plural check on GNU format with plural missing
+# Expected Result = valid
+msgid "Plural is missing"
+msgid_plural ""
+msgstr[0] "Singular is translated"
+msgstr[1] ""
+
+# KDE specific: desktop file contains whitespace transaltion
+# Expected Result = error
+msgid "Name=No Spaces"
+msgstr "Name= "
+