From bd9e6617827818fd043452c08c606f07b78014a0 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: 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 --- kbabel/datatools/pluralforms/Makefile.am | 19 +++ .../pluralforms/kbabel_pluralformstool.desktop | 101 ++++++++++++++++ kbabel/datatools/pluralforms/main.cc | 129 +++++++++++++++++++++ kbabel/datatools/pluralforms/main.h | 53 +++++++++ 4 files changed, 302 insertions(+) create mode 100644 kbabel/datatools/pluralforms/Makefile.am create mode 100644 kbabel/datatools/pluralforms/kbabel_pluralformstool.desktop create mode 100644 kbabel/datatools/pluralforms/main.cc create mode 100644 kbabel/datatools/pluralforms/main.h (limited to 'kbabel/datatools/pluralforms') diff --git a/kbabel/datatools/pluralforms/Makefile.am b/kbabel/datatools/pluralforms/Makefile.am new file mode 100644 index 00000000..b7d50e80 --- /dev/null +++ b/kbabel/datatools/pluralforms/Makefile.am @@ -0,0 +1,19 @@ + +INCLUDES = -I$(srcdir)/../../common -I../../common $(all_includes) +kbabel_pluraltool_la_LIBADD = $(LIB_KIO) ../../common/libkbabelcommon.la + +####### Files + +kde_module_LTLIBRARIES = kbabel_pluraltool.la + +kbabel_pluraltool_la_SOURCES = main.cc + +kbabel_pluraltool_la_LDFLAGS = $(all_libraries) -avoid-version -module -no-undefined + +noinst_HEADERS = main.h + +kbabel_pluraltool_la_METASOURCES = AUTO + +service_DATA = kbabel_pluralformstool.desktop +servicedir = $(kde_servicesdir) + diff --git a/kbabel/datatools/pluralforms/kbabel_pluralformstool.desktop b/kbabel/datatools/pluralforms/kbabel_pluralformstool.desktop new file mode 100644 index 00000000..5d579994 --- /dev/null +++ b/kbabel/datatools/pluralforms/kbabel_pluralformstool.desktop @@ -0,0 +1,101 @@ +[Desktop Entry] +Name=Plural Form Validation for KBabel +Name[bg]=Валидност на мн. форми - KBabel +Name[bs]=Provjera formi množine za KBabel +Name[ca]=Validació de les formes plurals per a KBabel +Name[cs]=Validace množného čísla +Name[cy]=Dilysu Ffurf Lluosryw i KBabel +Name[da]=Validering af flertalsformer for KBabel +Name[de]=Pluralform-Überprüfung für KBabel +Name[el]=Έλεγχος εγκυρότητας φορμών πληθυντικού για το KBabel +Name[es]=Validación de formas plurales para KBabel +Name[et]=KBabeli mitmusevormide kontrollija +Name[eu]=Plural forma balidazioa KBabel-entzat +Name[fa]=اعتبارسنجی شکل جمع برای KBabel +Name[fi]=Monikkomuotojen tarkistus KBabelissa +Name[fr]=Validation des formes plurielles pour KBabel +Name[gl]=Validación de formas do plural para KBabel +Name[hi]=के-बेबल के लिए बहुवचन फार्म वेलिडेशन +Name[hu]=A többes szám ellenőrzése a KBabelben +Name[is]=Staðfesting fleirtöluforma fyrir KBabel +Name[it]=Convalida delle forme plurali per KBabel +Name[ja]=KBabel 複数形検証 +Name[ka]=მრავლობითი ფორმების დამმოწმებელი KBabel-სთვის +Name[kk]=KBabel-дың көптік жалғауын тексеруі +Name[lt]=KBabel daugiskaitos formų patikros įrankis +Name[ms]=Pengesahan Bentuk Jama' untuk KBabel +Name[nb]=Sjekk flertallsformer i KBabel +Name[nds]=Pluralformprööv för KBabel +Name[ne]=केब्याबलका लागि बहुबचन प्रमाणीकरण +Name[nl]=Meervoudsvormenvalidatie voor KBabel +Name[nn]=Sjekk fleirtalsformer i KBabel +Name[pl]=Sprawdzenie form liczby mnogiej w KBabel +Name[pt]=Validação de Formas Plurais para o KBabel +Name[pt_BR]=Validação de Formas Plurais para o KBabel +Name[ru]=Проверка множественных форм для KBabel +Name[sk]=Kontrola množných čísel pre KBabel +Name[sl]=Potrjevalnik množinskih oblik za KBabel +Name[sr]=Овера облика множине за KBabel +Name[sr@Latn]=Overa oblika množine za KBabel +Name[sv]=Validering av pluralformer för Kbabel +Name[ta]= Kபாபேலலுக்கு தருமதிப்பு பன்மை வடிவம் +Name[tg]=Тафтиши шаклҳои бисёр барои KBabel +Name[tr]=KBabel için Çoklu Form Denetimi +Name[uk]=Перевірка форм множини для KBabel +Name[zh_CN]=KBabel 的复数形式检查器 +Name[zh_TW]=KBabel 的單複數型檢查器 +ValidationString=plural forms +X-KDE-Library=kbabel_pluraltool +Type=Service +Commands=validate +Comment=Check Plural Forms +Comment[bg]=Проверка на мн. форми +Comment[bs]=Provjeri forme množine +Comment[ca]=Comprova les formes plurals +Comment[cs]=Zkontrolovat množné číslo +Comment[cy]=Gwirio Ffurfiau Lluosryw +Comment[da]=Tjek flertalsformer +Comment[de]=Überprüfung von Plural-Formen +Comment[el]=Έλεγχος φορμών πληθυντικού +Comment[es]=Comprobar formas plurales +Comment[et]=Mitmuse vormide kontroll +Comment[eu]=Egiaztatu plural formak +Comment[fa]=بررسی شکلهای جمع +Comment[fi]=Tarkista monikkomuodot +Comment[fr]=Vérifie les formes plurielles +Comment[gl]=Verificación de formas plurais +Comment[he]=בודק מצבי רבים +Comment[hi]=बहुवचन जाँचें +Comment[hu]=A többes számú alakok ellenőrzése +Comment[is]=Athuga fleirtöluform +Comment[it]=Controlla forme plurali +Comment[ja]=複数形を検証 +Comment[ka]=მრავლობითი ფორმების შემოწმება +Comment[kk]=Көптік жалғауын тексеру +Comment[lt]=Tikrinti daugiskaitos formas +Comment[ms]=Periksa Bentuk Jama' +Comment[nb]=Sjekk flertallsformer +Comment[nds]=Pluralformen pröven +Comment[ne]=बहुबचन जाँच गर्नुहोस् +Comment[nl]=Meervoudsvormen controleren +Comment[nn]=Sjekk fleirtalsformer +Comment[pa]=ਬਹੁ-ਵਚਨ ਫਾਰਮ ਜਾਂਚ +Comment[pl]=Sprawdzenie form liczby mnogiej +Comment[pt]=Verificação de Formas Plurais +Comment[pt_BR]=Verifica Formas Plurais +Comment[ru]=Проверить множественные формы +Comment[sk]=Kontrola množných čísel +Comment[sl]=Preveri množinske oblike +Comment[sr]=Провери облике множине +Comment[sr@Latn]=Proveri oblike množine +Comment[sv]=Kontrollera pluralformer +Comment[ta]= சரிபார்ப்பு +Comment[tg]=Тафтиш кардани шаклҳои бисёр +Comment[tr]=Çoklu Formları denetle +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/pluralforms/main.cc b/kbabel/datatools/pluralforms/main.cc new file mode 100644 index 00000000..a534df6e --- /dev/null +++ b/kbabel/datatools/pluralforms/main.cc @@ -0,0 +1,129 @@ +/* This file is part of KBabel + based Copyright (C) 1998, 1999 Torben Weis + 2002 Stanislav Visnovsky + + 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 +#include "catalog.h" +#include "catalogitem.h" +#include "catalogsettings.h" +#include "main.h" + +#include +#include +#include +#include +#include +#include + +/*************************************************** + * + * Factory + * + ***************************************************/ + +K_EXPORT_COMPONENT_FACTORY( kbabel_pluraltool, KGenericFactory ( "kbabeldatatool" ) ) + +using namespace KBabel; + +PluralsTool::PluralsTool( QObject* parent, const char* name, const QStringList & ) + : KDataTool( parent, name ), _cache_origin( 0 ), _neededForms(-1) +{ + i18n("what check found errors", "plural forms"); +} + +bool PluralsTool::run( const QString& command, void* data, const QString& datatype, const QString& mimetype ) +{ + if ( command != "validate" ) + { + kdDebug(KBABEL) << "Plural Forms Tool does only accept the command 'validate' and 'shortcut'" << endl; + kdDebug(KBABEL) << " The commands " << command << " is not accepted" << endl; + return FALSE; + } + + // Check wether we can accept the data + if ( datatype != "CatalogItem" ) + { + kdDebug(KBABEL) << "Plural Forms Tool only accepts datatype CatalogItem" << endl; + return FALSE; + } + + if ( mimetype != "application/x-kbabel-catalogitem" ) + { + kdDebug(KBABEL) << "Plural Forms Tool only accepts mimetype application/x-kbabel-catalogitem" << endl; + return FALSE; + } + + if( command == "validate" ) + { + if( _neededForms < 0 ) + { + Catalog* cat = new Catalog(this); + _neededForms = cat->defaultNumberOfPluralForms(); + delete cat; + } + + CatalogItem* item = (CatalogItem*)(data); + + if( _cache_origin != item->project() ) + { + _plurals = item->project()->miscSettings().singularPlural; + _cache_origin = item->project(); + } + + bool hasError = false; + + if(!item->isUntranslated() && item->pluralForm() == KDESpecific ) + { + if(_neededForms <= 0 || item->msgstr().first().contains(_plurals)) + { + hasError = true; + } + else if( item->msgstr().first().contains(QString("\\n"))+1 != _neededForms ) + { + hasError = true; + } + } + + if(hasError) + { + item->appendError( "plural forms" ); + } + else + { + item->removeError( "plural forms" ); + } + + return !hasError; + } + return FALSE; +} + +#include "main.moc" diff --git a/kbabel/datatools/pluralforms/main.h b/kbabel/datatools/pluralforms/main.h new file mode 100644 index 00000000..1537f38f --- /dev/null +++ b/kbabel/datatools/pluralforms/main.h @@ -0,0 +1,53 @@ +/* This file is part of KBabel + based on Copyright (C) 1998, 1999 Torben Weis + 2002 Stanislav Visnovsky + + 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 + +class PluralsTool : public KDataTool +{ + Q_OBJECT + +public: + PluralsTool( 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; + int _neededForms; +}; + +#endif -- cgit v1.2.1