[ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 /********************************************************************** 2 ** Copyright (C) 2000 Trolltech AS. All rights reserved. 3 ** 4 ** sametexth.cpp 5 ** 6 ** This file is part of Qt Linguist. 7 ** 8 ** See the file LICENSE included in the distribution for the usage 9 ** and distribution terms. 10 ** 11 ** The file is provided AS IS with NO WARRANTY OF ANY KIND, 12 ** INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR 13 ** A PARTICULAR PURPOSE. 14 ** 15 **********************************************************************/ 16 17 #include <qcstring.h> 18 #include <qmap.h> 19 20 #include <metatranslator.h> 21 22 typedef QMap<QCString, MetaTranslatorMessage> TMM; 23 typedef QValueList<MetaTranslatorMessage> TML; 24 25 /* 26 Augments a MetaTranslator with trivially derived translations. 27 28 For example, if "Enabled:" is consistendly translated as "Eingeschaltet:" no 29 matter the context or the comment, "Eingeschaltet:" is added as the 30 translation of any untranslated "Enabled:" text and is marked Unfinished. 31 */ 32 33 void applySameTextHeuristic( MetaTranslator *tor, bool verbose ) 34 { 35 TMM translated, avoid; 36 TMM::Iterator t; 37 TML untranslated; 38 TML::Iterator u; 39 TML all = tor->messages(); 40 TML::Iterator it; 41 int inserted = 0; 42 43 for ( it = all.begin(); it != all.end(); ++it ) { 44 if ( (*it).type() == MetaTranslatorMessage::Unfinished ) { 45 if ( (*it).translation().isEmpty() ) 46 untranslated.append( *it ); 47 } else { 48 QCString key = (*it).sourceText(); 49 t = translated.find( key ); 50 if ( t != translated.end() ) { 51 /* 52 The same source text is translated at least two 53 different ways. Do nothing then. 54 */ 55 if ( (*t).translation() != (*it).translation() ) { 56 translated.remove( key ); 57 avoid.insert( key, *it ); 58 } 59 } else if ( !avoid.contains(key) ) { 60 translated.insert( key, *it ); 61 } 62 } 63 } 64 65 for ( u = untranslated.begin(); u != untranslated.end(); ++u ) { 66 QCString key = (*u).sourceText(); 67 t = translated.find( key ); 68 if ( t != translated.end() ) { 69 MetaTranslatorMessage m( *u ); 70 m.setTranslation( (*t).translation() ); 71 tor->insert( m ); 72 inserted++; 73 } 74 } 75 if ( verbose && inserted != 0 ) 76 qWarning( " same-text heuristic provided %d translation%s", 77 inserted, inserted == 1 ? "" : "s" ); 78 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Feb 24 10:30:04 2007 | par Balluche grâce à PHPXref 0.7 |