summaryrefslogtreecommitdiff
path: root/development/translation/shared/metatranslator.cpp
Unidiff
Diffstat (limited to 'development/translation/shared/metatranslator.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--development/translation/shared/metatranslator.cpp34
1 files changed, 22 insertions, 12 deletions
diff --git a/development/translation/shared/metatranslator.cpp b/development/translation/shared/metatranslator.cpp
index a01e1eb..51270c5 100644
--- a/development/translation/shared/metatranslator.cpp
+++ b/development/translation/shared/metatranslator.cpp
@@ -9,8 +9,14 @@
9** packaging of this file. 9** packaging of this file.
10** 10**
11** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
12** licenses may use this file in accordance with the Qt Commercial License
13** Agreement provided with the Software.
14**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 15** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 16** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 17**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 18** See http://www.trolltech.com/gpl/ for GPL licensing information.
19** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
20** information about Qt Commercial License Agreements.
15** 21**
16** Contact info@trolltech.com if any conditions of this licensing are 22** Contact info@trolltech.com if any conditions of this licensing are
@@ -139,9 +145,11 @@ bool TsHandler::endElement( const QString& /* namespaceURI */,
139 } else { 145 } else {
140 if ( contextIsUtf8 ) 146 if ( contextIsUtf8 )
141 tor->insert( MetaTranslatorMessage(context.utf8(), "", 147 tor->insert( MetaTranslatorMessage(context.utf8(),
148 ContextComment,
142 accum.utf8(), QString::null, TRUE, 149 accum.utf8(), QString::null, TRUE,
143 MetaTranslatorMessage::Unfinished) ); 150 MetaTranslatorMessage::Unfinished) );
144 else 151 else
145 tor->insert( MetaTranslatorMessage(context.ascii(), "", 152 tor->insert( MetaTranslatorMessage(context.ascii(),
153 ContextComment,
146 accum.ascii(), QString::null, FALSE, 154 accum.ascii(), QString::null, FALSE,
147 MetaTranslatorMessage::Unfinished) ); 155 MetaTranslatorMessage::Unfinished) );
@@ -316,6 +324,6 @@ bool MetaTranslatorMessage::operator<( const MetaTranslatorMessage& m ) const
316 324
317MetaTranslator::MetaTranslator() 325MetaTranslator::MetaTranslator()
318 : codecName( "ISO-8859-1" ), codec( 0 )
319{ 326{
327 clear();
320} 328}
321 329
@@ -323,5 +331,4 @@ MetaTranslator::MetaTranslator( const MetaTranslator& tor )
323 : mm( tor.mm ), codecName( tor.codecName ), codec( tor.codec ) 331 : mm( tor.mm ), codecName( tor.codecName ), codec( tor.codec )
324{ 332{
325
326} 333}
327 334
@@ -334,8 +341,13 @@ MetaTranslator& MetaTranslator::operator=( const MetaTranslator& tor )
334} 341}
335 342
336bool MetaTranslator::load( const QString& filename ) 343void MetaTranslator::clear()
337{ 344{
338 mm.clear(); 345 mm.clear();
346 codecName = "ISO-8859-1";
347 codec = 0;
348}
339 349
350bool MetaTranslator::load( const QString& filename )
351{
340 QFile f( filename ); 352 QFile f( filename );
341 if ( !f.open(IO_ReadOnly) ) 353 if ( !f.open(IO_ReadOnly) )
@@ -345,5 +357,4 @@ bool MetaTranslator::load( const QString& filename )
345 QXmlInputSource in( t ); 357 QXmlInputSource in( t );
346 QXmlSimpleReader reader; 358 QXmlSimpleReader reader;
347 // don't click on these!
348 reader.setFeature( "http://xml.org/sax/features/namespaces", FALSE ); 359 reader.setFeature( "http://xml.org/sax/features/namespaces", FALSE );
349 reader.setFeature( "http://xml.org/sax/features/namespace-prefixes", TRUE ); 360 reader.setFeature( "http://xml.org/sax/features/namespace-prefixes", TRUE );
@@ -359,6 +370,4 @@ bool MetaTranslator::load( const QString& filename )
359 delete hand; 370 delete hand;
360 f.close(); 371 f.close();
361 if ( !ok )
362 mm.clear();
363 return ok; 372 return ok;
364} 373}
@@ -385,5 +394,5 @@ bool MetaTranslator::save( const QString& filename ) const
385 394
386 do { 395 do {
387 if ( QCString(m.key().sourceText()).isEmpty() ) { 396 if ( QCString(m.key().sourceText()) == ContextComment ) {
388 if ( m.key().type() != MetaTranslatorMessage::Obsolete ) { 397 if ( m.key().type() != MetaTranslatorMessage::Obsolete ) {
389 contextIsUtf8 = m.key().utf8(); 398 contextIsUtf8 = m.key().utf8();
@@ -438,5 +447,6 @@ bool MetaTranslator::save( const QString& filename ) const
438} 447}
439 448
440bool MetaTranslator::release( const QString& filename, bool verbose ) const 449bool MetaTranslator::release( const QString& filename, bool verbose,
450 QTranslator::SaveMode mode ) const
441{ 451{
442 QTranslator tor( 0 ); 452 QTranslator tor( 0 );
@@ -480,5 +490,5 @@ bool MetaTranslator::release( const QString& filename, bool verbose ) const
480 } 490 }
481 491
482 bool saved = tor.save( filename, QTranslator::Stripped ); 492 bool saved = tor.save( filename, mode );
483 if ( saved && verbose ) 493 if ( saved && verbose )
484 fprintf( stderr, 494 fprintf( stderr,
@@ -524,5 +534,5 @@ void MetaTranslator::stripEmptyContexts()
524 TMM::Iterator m = mm.begin(); 534 TMM::Iterator m = mm.begin();
525 while ( m != mm.end() ) { 535 while ( m != mm.end() ) {
526 if ( QCString(m.key().sourceText()).isEmpty() ) { 536 if ( QCString(m.key().sourceText()) == ContextComment ) {
527 TMM::Iterator n = m; 537 TMM::Iterator n = m;
528 ++n; 538 ++n;