diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | bd9e6617827818fd043452c08c606f07b78014a0 (patch) | |
tree | 425bb4c3168f9c02f10150f235d2cb998dcc6108 /kbabel/filters/xliff | |
download | tdesdk-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/filters/xliff')
-rw-r--r-- | kbabel/filters/xliff/Makefile.am | 18 | ||||
-rw-r--r-- | kbabel/filters/xliff/kbabel_xliff_export.desktop | 47 | ||||
-rw-r--r-- | kbabel/filters/xliff/kbabel_xliff_import.desktop | 47 | ||||
-rw-r--r-- | kbabel/filters/xliff/xliffexport.cpp | 223 | ||||
-rw-r--r-- | kbabel/filters/xliff/xliffexport.h | 66 | ||||
-rw-r--r-- | kbabel/filters/xliff/xliffimport.cpp | 180 | ||||
-rw-r--r-- | kbabel/filters/xliff/xliffimport.h | 68 |
7 files changed, 649 insertions, 0 deletions
diff --git a/kbabel/filters/xliff/Makefile.am b/kbabel/filters/xliff/Makefile.am new file mode 100644 index 00000000..d3f6cab1 --- /dev/null +++ b/kbabel/filters/xliff/Makefile.am @@ -0,0 +1,18 @@ +####### General stuff + +INCLUDES = -I../../common -I$(srcdir)/../../common $(all_includes) + +kde_module_LTLIBRARIES = kbabel_xliffexport.la kbabel_xliffimport.la + +kbabel_xliffexport_la_SOURCES = xliffexport.cpp +kbabel_xliffexport_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries) +kbabel_xliffexport_la_LIBADD = ../../common/libkbabelcommon.la + +kbabel_xliffimport_la_SOURCES = xliffimport.cpp +kbabel_xliffimport_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries) +kbabel_xliffimport_la_LIBADD = ../../common/libkbabelcommon.la + +METASOURCES = AUTO + +service_DATA = kbabel_xliff_export.desktop kbabel_xliff_import.desktop +servicedir = $(kde_servicesdir) diff --git a/kbabel/filters/xliff/kbabel_xliff_export.desktop b/kbabel/filters/xliff/kbabel_xliff_export.desktop new file mode 100644 index 00000000..d4a8036d --- /dev/null +++ b/kbabel/filters/xliff/kbabel_xliff_export.desktop @@ -0,0 +1,47 @@ +[Desktop Entry] +Type=Service +Name=KBabel XLIFF Export Filter +Name[bg]=XLIFF филтър за експортиране - KBabel +Name[br]=Sil ezporzh XLIFF evit KBabel +Name[ca]=Filtre KBabel per exportar a XLIFF +Name[cs]=Exportní filtr do XLIFF pro KBabel +Name[da]=KBabel XLIFF eksportfilter +Name[de]=XLIFF-Export-Filter für KBabel +Name[el]=Φίλτρο εξαγωγής XLIFF του KBabel +Name[es]=Filtro de exportación XLIFF de KBabel +Name[et]=KBabeli XLIFF ekspordifilter +Name[eu]=KBabel XLIFF esportazio iragazkia +Name[fa]=پالایۀ صادرات XLIFF KBabel +Name[fi]=KBabel XLIFF -vientisuodatin +Name[fr]=Filtre d'exportation XLIFF pour KBabel +Name[ga]=Scagaire Easpórtála XLIFF le haghaidh KBabel +Name[gl]=Filtro de exportación a XLIFF para KBabel +Name[hu]=KBabel XLIFF exportszűrő +Name[is]=KBabel XLIFF útfluttningssía +Name[it]=Filtro di esportazione XLIFF per KBabel +Name[ja]=KBabel XLIFF エクスポートフィルタ +Name[ka]=KBabel XLIFF ექსპორტის ფილტრი +Name[kk]=KBabel XLIFF экспорттау сүзгісі +Name[lt]=KBabel XLIFF eksportavimo filtras +Name[nb]=XLIFF-eksportfilter for KBabel +Name[nds]=KBabel-Exportfilter för XLIFF +Name[ne]=केब्याबल एक्सएलआईएफएफ निर्यात फिल्टर +Name[nl]=KBabel XLIFF-exportfilter +Name[nn]=XLIFF-eksportfilter for KBabel +Name[pa]=ਕੇਬਬੇਲ XLIFF ਨਿਰਯਾਤ ਫਿਲਟਰ +Name[pl]=Filtr KBabel do eksportu do formatu XLIFF +Name[pt]=Filtro de Exportação XLIFF para o KBabel +Name[pt_BR]=Filtro de Exportação XLIFF do KBabel +Name[ru]=Фильтр экспорта XLIFF +Name[sk]=Exportný filter pre KBabel XLIFF +Name[sl]=Izvozni filter XLIFF za KBabel +Name[sr]=KBabel-ов филтер за извоз у XLIFF +Name[sr@Latn]=KBabel-ov filter za izvoz u XLIFF +Name[sv]=Kbabel exportfilter för XLIFF +Name[tr]=KBabel XLIFF Dışa Aktarma Süzgeci +Name[uk]=Фільтр експорту XLIFF для KBabel +Name[zh_CN]=KBabel XLIFF 导出过滤器 +Name[zh_TW]=KBabel XLIFF 匯出過濾器 +X-KDE-Library=kbabel_xliffexport +X-KDE-Export=application/x-xliff +ServiceTypes=KBabelFilter diff --git a/kbabel/filters/xliff/kbabel_xliff_import.desktop b/kbabel/filters/xliff/kbabel_xliff_import.desktop new file mode 100644 index 00000000..260a30b4 --- /dev/null +++ b/kbabel/filters/xliff/kbabel_xliff_import.desktop @@ -0,0 +1,47 @@ +[Desktop Entry] +Type=Service +Name=KBabel XLIFF Import Filter +Name[bg]=XLIFF филтър за импортиране - KBabel +Name[br]=Sil enporzh XLIFF evit KBabel +Name[ca]=Filtre KBabel per importar de XLIFF +Name[cs]=Importní filtr XLIFF pro KBabel +Name[da]=KBabel XLIFF importfilter +Name[de]=XLIFF-Import-Filter für KBabel +Name[el]=Φίλτρο εισαγωγής XLIFF του KBabel +Name[es]=Filtro de importación de XLIFF de KBabel +Name[et]=KBabeli XLIFF impordifilter +Name[eu]=KBabel XLIFF inportazio iragazkia +Name[fa]=پالایۀ واردات XLIFF KBabel +Name[fi]=KBabel XLIFF -tuontisuodatin +Name[fr]=Filtre d'importation XLIFF pour KBabel +Name[ga]=Scagaire Iompórtála XLIFF le haghaidh KBabel +Name[gl]=Filtro de importación a XLIFF para KBabel +Name[hu]=KBabel XLIFF importszűrő +Name[is]=KBabel XLIFF innfluttningssía +Name[it]=Filtro di importazione di XLIFF per KBabel +Name[ja]=KBabel XLIFF インポートフィルタ +Name[ka]=KBabel XLIFF იმპორის ფილტრი +Name[kk]=KBabel XLIFF импорттау сүзгісі +Name[lt]=KBabel XLIFF importavimo filtras +Name[nb]=XLIFF-importfilter for KBabel +Name[nds]=KBabel-Importfilter för XLIFF +Name[ne]=केब्याबल एक्सएलआईएफएफ आयात फिल्टर +Name[nl]=KBabel XLIFF-importfilter +Name[nn]=XLIFF-importfilter for KBabel +Name[pa]=ਕੇਬਬੇਲ XLIFF ਅਯਾਤ ਫਿਲਟਰ +Name[pl]=Filtr KBabel do importu z formatu XLIFF +Name[pt]=Filtro de Importação XLIFF para o KBabel +Name[pt_BR]=Filtro de Importação XLIFF para o KBabel +Name[ru]=Фильтр импорта XLIFF +Name[sk]=Importný filter pre KBabel XLIFF +Name[sl]=Uvozni filter XLIFF za KBabel +Name[sr]=KBabel-ов филтер за увоз из XLIFF-а +Name[sr@Latn]=KBabel-ov filter za uvoz iz XLIFF-a +Name[sv]=Kbabel importfilter för XLIFF +Name[tr]=KBabel XLIFF İçe Aktarma Süzgeci +Name[uk]=Фільтр імпорту XLIFF для KBabel +Name[zh_CN]=KBabel XLIFF 导入过滤器 +Name[zh_TW]=KBabel XLIFF 匯入過濾器 +X-KDE-Library=kbabel_xliffimport +X-KDE-Import=application/x-xliff +ServiceTypes=KBabelFilter diff --git a/kbabel/filters/xliff/xliffexport.cpp b/kbabel/filters/xliff/xliffexport.cpp new file mode 100644 index 00000000..53527f2c --- /dev/null +++ b/kbabel/filters/xliff/xliffexport.cpp @@ -0,0 +1,223 @@ +/* **************************************************************************** + This file is part of KBabel + + Copyright (C) 1999-2000 by Matthias Kiefer + <matthias.kiefer@gmx.de> + 2001-2004 by Stanislav Visnovsky + <visnovsky@kde.org> + 2002-2003 by Marco Wegner + <mail@marcowegner.de> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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 <qfile.h> +#include "qregexp.h" +#include <qstring.h> +#include <qstringlist.h> +#include <qtextstream.h> + +#include <kgenericfactory.h> + +#include "catalog.h" +#include "catalogitem.h" +#include "catalogsettings.h" +#include "xliffexport.h" + +K_EXPORT_COMPONENT_FACTORY( kbabel_xliffexport, KGenericFactory<XLIFFExportPlugin> ( "kbabelxliffexportfilter" ) ) + +using namespace KBabel; + +XLIFFExportPlugin::XLIFFExportPlugin( QObject * parent, const char * name, const QStringList& ) + : CatalogExportPlugin( parent, name ) +{ +} + +ConversionStatus XLIFFExportPlugin::save( const QString& filename, const QString&, const Catalog * catalog ) +{ + // Check whether we know how to handle the extra data. + if ( catalog->importPluginID( ) != "XLIFF 1.1" ) + return UNSUPPORTED_TYPE; + + QFile file( filename ); + if ( !file.open( IO_WriteOnly ) ) + return OS_ERROR; + + SaveSettings settings = catalog->saveSettings( ); + + // New DOM document. + QDomDocument doc( "" ); + + extraData = catalog->catalogExtraData(); + kdDebug () << "Setting the document data: " << extraData.first () << endl; + doc.setContent ( extraData.first () ); + + // Regular messages. + for ( uint i = 0; i < catalog->numberOfEntries( ); i++ ) { + QDomElement element = extractComment( doc, *(extraData.at( i+1 )) ); + createMessage( doc, element, catalog->msgid( i ).join( "" ), catalog->msgstr( i ).join( "" ) ); + } + + QTextStream stream( &file ); + doc.save( stream, 2 ); + file.close( ); + + return OK; +} + +QDomElement XLIFFExportPlugin::extractComment( QDomDocument& doc, const QString& s ) +{ + QString comment( s ); + + if ( comment.isEmpty () ) + { + kdError () << "Empty comment, should not happen" << endl; + } + + // Extract the context and the actual comment. + comment.remove( QRegExp( "^Context:[\\s]*" ) ); + QString newContext; + QStringList commentlines = QStringList::split ( '\n', comment); + + QString file = *(commentlines.at(0)); + QString id = *(commentlines.at(1)); + + kdDebug () << "Looking for file " << file << endl; + + return getContext( doc, file, id ); +} + +void XLIFFExportPlugin::createMessage( QDomDocument& doc, QDomElement& translationElement, const QString& msgid, + const QString& msgstr ) +{ + // for empty messages, don't store anything + if (msgstr.isEmpty ()) + return; + + // find the trans element + QDomNode node = translationElement.firstChild( ); + while ( !node.isNull( ) ) { + kdDebug () << node.nodeName () << endl; + if ( node.isElement() && node.toElement().tagName( ) == "target") { + kdDebug () << "Found the target: " << + node.firstChild().nodeName () << endl; + // set the new translation + node.firstChild().toText().setData (msgstr); + break; + } + node = node.nextSibling( ); + } + + if ( node.isNull () ) + { + // no target tag, create one + node = doc.createElement ("target"); + translationElement.appendChild (node); + + QDomText data = doc.createTextNode(msgstr ); + node.appendChild( data ); + } +} + +QDomElement XLIFFExportPlugin::getContext( QDomDocument& doc, const QString& file, const QString& id ) +{ + // Find out whether there is already such a context in the QDomDocument. + QDomNode parentelem = doc.documentElement(); + QDomNode elem = doc.documentElement( ).firstChild( ); + while ( !elem.isNull( ) ) { + if ( elem.isElement( ) && elem.toElement().tagName( ) == "file" && elem.toElement().attribute ("original") == file ) { + kdDebug () << "We have found the file" << endl; + break; + } + elem = elem.nextSibling( ); + } + + if (elem.isNull ()) + { + kdError () << "File not found at all, creating" << endl; + QDomElement newelem = doc.createElement ("file"); + newelem.setAttribute ("original", file); + parentelem.appendChild (newelem); + elem = newelem; + } + + // lookup body tag + parentelem = elem; + elem = elem.firstChild (); + while ( !elem.isNull( ) ) { + if ( elem.isElement( ) && elem.toElement().tagName( ) == "body" ) { + kdDebug () << "We have found the file body" << endl; + break; + } + elem = elem.nextSibling( ); + } + + if (elem.isNull ()) + { + kdError () << "File body not found at all, creating" << endl; + QDomElement newelem = doc.createElement ("body"); + parentelem.appendChild (newelem); + elem = newelem; + } + + elem = findTransUnit (elem, id); + + if (elem.isNull ()) + { + kdError () << "Trans-unit not found at all, creating" << endl; + QDomElement newelem = doc.createElement ("trans-unit"); + newelem.setAttribute ("id", id); + parentelem.appendChild (newelem); + elem = newelem; + } + + return elem.toElement (); +} + +QDomElement XLIFFExportPlugin::findTransUnit( QDomNode& group, const QString& id ) +{ + QDomNode elem = group.firstChild( ); + + // lookup correct trans-unit tag + while ( !elem.isNull( ) ) { + if ( elem.isElement( ) && elem.toElement().tagName() == "group" ) + { + // search recursively + QDomElement res = findTransUnit( elem, id ); + if (! res.isNull () ) + return res.toElement(); + } + else if ( elem.isElement( ) && elem.toElement().tagName( ) == "trans-unit" && elem.toElement().attribute ("id") == id ) { + kdDebug () << "We have found the trans-unit" << endl; + return elem.toElement (); + } + elem = elem.nextSibling( ); + } + + return elem.toElement (); +} diff --git a/kbabel/filters/xliff/xliffexport.h b/kbabel/filters/xliff/xliffexport.h new file mode 100644 index 00000000..5bf64b25 --- /dev/null +++ b/kbabel/filters/xliff/xliffexport.h @@ -0,0 +1,66 @@ +/* **************************************************************************** + This file is part of KBabel + + Copyright (C) 2002-2004 by Stanislav Visnovsky + <visnovsky@kde.org> + 2002-2003 by Marco Wegner + <mail@marcowegner.de> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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 XLIFFEXPORT_H +#define XLIFFEXPORT_H + +#include <qdom.h> + +#include "catalogfileplugin.h" + +class QString; +class QStringList; + +namespace KBabel { +class Catalog; +} + +class XLIFFExportPlugin : public KBabel::CatalogExportPlugin +{ + public: + XLIFFExportPlugin( QObject * parent, const char * name, const QStringList& ); + virtual KBabel::ConversionStatus save( const QString& filename, const QString& mimetype, const KBabel::Catalog * catalog ); + + private: + QDomElement extractComment( QDomDocument& doc, const QString& s ); + void createMessage( QDomDocument& doc, QDomElement& context, const QString& msgid, const QString& msgstr ); + QDomElement getContext( QDomDocument& doc, const QString& file, const QString& id); + QDomElement findTransUnit( QDomNode& doc, const QString& id); + + QStringList extraData; +}; + +#endif // XLIFFEXPORT_H diff --git a/kbabel/filters/xliff/xliffimport.cpp b/kbabel/filters/xliff/xliffimport.cpp new file mode 100644 index 00000000..f7de63ce --- /dev/null +++ b/kbabel/filters/xliff/xliffimport.cpp @@ -0,0 +1,180 @@ +// kate: space-indent on; indent-width 2; replace-tabs on; + +/* **************************************************************************** + This file is part of KBabel + + Copyright (C) 1999-2000 by Matthias Kiefer + <matthias.kiefer@gmx.de> + 2001-2004 by Stanislav Visnovsky + <visnovsky@kde.org> + 2002-2003 by Marco Wegner + <mail@marcowegner.de> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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. + +**************************************************************************** */ + + +/******* + design: + + the file name and id data are stored in the comment like this: + file\n + id\n + optional comments + */ + +// Qt include files +#include <qfile.h> +#include <qfileinfo.h> +#include <qobject.h> +#include <qregexp.h> +#include <qstring.h> +#include <qstringlist.h> +// KDE include files +#include <kdebug.h> +#include <kgenericfactory.h> +// Project specific include files +#include "catalogitem.h" +#include "xliffimport.h" + +// ### TODO: what is the kdebug area? +#define KDEBUG_AREA + +K_EXPORT_COMPONENT_FACTORY( kbabel_xliffimport, KGenericFactory<XLIFFImportPlugin> ( "kbabelxliffimportfilter" ) ) + +using namespace KBabel; + +XLIFFImportPlugin::XLIFFImportPlugin( QObject * parent, const char * name, const QStringList& ) + : CatalogImportPlugin( parent, name ) +{ +} + +ConversionStatus XLIFFImportPlugin::load( const QString& filename, const QString& ) +{ + if ( filename.isEmpty( ) ) { + kdDebug( KDEBUG_AREA ) << "fatal error: empty filename to open" << endl; + return NO_FILE; + } + + QFileInfo info( filename ); + + if ( !info.exists( ) || info.isDir( ) ) + return NO_FILE; + + if ( !info.isReadable( ) ) + return NO_PERMISSIONS; + + QFile file( filename ); + if ( !file.open( IO_ReadOnly ) ) + return NO_PERMISSIONS; + + QString errorMsg; + int errorLine, errorColumn; + + QDomDocument doc; + if ( !doc.setContent( &file, &errorMsg, &errorLine, &errorColumn ) ) { + file.close( ); + kdError ( KDEBUG_AREA ) << "Parsing error at line " << errorLine << ", column " << errorColumn << ", error " << errorMsg << endl; + return PARSE_ERROR; + } + file.close( ); + + extraData.clear(); + + const QDomElement documentElement( doc.documentElement() ); + msgcnt = documentElement.elementsByTagName( "trans-unit" ).count(); + + extraData.append( doc.toString() ); + + cnt = 0; + emit signalClearProgressBar( ); + kdDebug( KDEBUG_AREA ) << "start parsing..." << endl; + + parse( documentElement ); + + // store full document in extra data at index 0, the rest + // contains contexts for each entry at(1) for entry 0, at(2) for entry 1 ... + setCatalogExtraData( extraData ); + + emit signalProgress( 100 ); + kdDebug( KDEBUG_AREA ) << "finished parsing..." << endl; + + setMimeTypes( "application/x-xliff" ); + + return OK; +} + +void XLIFFImportPlugin::parse( const QDomElement& parentElement ) +{ + QDomNode node = parentElement.firstChild( ); + + while ( !node.isNull( ) ) { + if ( node.isElement( ) ) { + QDomElement elem = node.toElement( ); + + if ( elem.tagName( ) == "body" ) { + // nothing to do here + } else if ( elem.tagName( ) == "file" ) { + context = elem.attribute( "original", QString() ); + kdDebug ( KDEBUG_AREA ) << "Found file: " << context << endl; + } else if ( elem.tagName( ) == "trans-unit" ) { + CatalogItem item; + QString comment; + bool isObsolete = false; + + const QString id = elem.attribute ("id"); + + QDomNode childNode = node.firstChild(); + for ( ; ! childNode.isNull() ; childNode = childNode.nextSibling() ) + { + if ( childNode.isElement() ) + { + const QDomElement elem = childNode.toElement( ); + if ( elem.tagName( ) == "source" ) { + item.setMsgid( elem.text( ) ); + } else if ( elem.tagName( ) == "target" ) { + item.setMsgstr( elem.text( ) ); + } + } + } + + extraData.append ( context + '\n' + id ); + item.setComment( "Context: " + context + '\n' + id + "\n" + comment ); + + appendCatalogItem( item, isObsolete ); + + // Update the progress bar. + cnt++; + uint prog = 100*cnt/msgcnt; + emit signalProgress( prog ); + } + // recursive parsing + parse( elem ); + } + node = node.nextSibling( ); + } +} diff --git a/kbabel/filters/xliff/xliffimport.h b/kbabel/filters/xliff/xliffimport.h new file mode 100644 index 00000000..9cf44835 --- /dev/null +++ b/kbabel/filters/xliff/xliffimport.h @@ -0,0 +1,68 @@ +/* **************************************************************************** + This file is part of KBabel + + Copyright (C) 2002-2004 by Stanislav Visnovsky + <visnovsky@kde.org> + 2002-2003 by Marco Wegner + <mail@marcowegner.de> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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 XLIFFIMPORT_H +#define XLIFFIMPORT_H + +#include <qdom.h> + +#include "catalogfileplugin.h" + +class QString; +class QStringList; + +/** + * The class for importing XLIFF 1.1 translation source files. + */ +class XLIFFImportPlugin : public KBabel::CatalogImportPlugin +{ + public: + XLIFFImportPlugin( QObject * parent, const char * name, const QStringList& ); + + virtual KBabel::ConversionStatus load( const QString& filename, const QString& mimetype ); + virtual const QString id( ) { return "XLIFF 1.1"; } + + private: + void parse( const QDomElement& parentElement ); + + private: + uint msgcnt; + uint cnt; + QString context; + QStringList extraData; +}; + +#endif // XLIFFIMPORT_H |