[ Index ]
 

Code source de eZ Publish 3.9.0

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/support/lupdate-ezpublish3/ -> merge.cpp (source)

   1  /**********************************************************************
   2  **   Copyright (C) 2000 Trolltech AS.  All rights reserved.
   3  **
   4  **   merge.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 <metatranslator.h>
  18  
  19  // defined in numberh.cpp
  20  extern void applyNumberHeuristic( MetaTranslator *tor, bool verbose );
  21  // defined in sametexth.cpp
  22  extern void applySameTextHeuristic( MetaTranslator *tor, bool verbose );
  23  
  24  typedef QValueList<MetaTranslatorMessage> TML;
  25  
  26  /*
  27    Merges two MetaTranslator objects into the first one.  The first one is a set
  28    of source texts and translations for a previous version of the
  29    internationalized program; the second one is a set of fresh source text newly
  30    extracted from the source code, without any translation yet.
  31  */
  32  
  33  void merge( MetaTranslator *tor, const MetaTranslator *virginTor, const QString &language, bool verbose )
  34  {
  35      int known = 0;
  36      int neww = 0;
  37      int obsoleted = 0;
  38      TML all = tor->messages();
  39      TML::Iterator it;
  40  
  41      /*
  42        The types of all the messages from the vernacular translator are updated
  43        according to the virgin translator.
  44      */
  45      for ( it = all.begin(); it != all.end(); ++it ) {
  46      MetaTranslatorMessage::Type newType;
  47      MetaTranslatorMessage m = *it;
  48  
  49      // skip context comment
  50      if ( !QCString((*it).sourceText()).isEmpty() ) {
  51          if ( !virginTor->contains((*it).context(), (*it).sourceText(),
  52                        (*it).comment()) ) {
  53          newType = MetaTranslatorMessage::Obsolete;
  54          if ( m.type() != MetaTranslatorMessage::Obsolete )
  55              obsoleted++;
  56          } else {
  57          switch ( m.type() ) {
  58          case MetaTranslatorMessage::Finished:
  59              newType = MetaTranslatorMessage::Finished;
  60              known++;
  61              break;
  62          case MetaTranslatorMessage::Unfinished:
  63              newType = MetaTranslatorMessage::Unfinished;
  64              known++;
  65              break;
  66          case MetaTranslatorMessage::Obsolete:
  67              newType = MetaTranslatorMessage::Unfinished;
  68              neww++;
  69          }
  70          }
  71  
  72          if ( newType != m.type() ) {
  73          m.setType( newType );
  74          tor->insert( m );
  75          }
  76      }
  77      }
  78  
  79      /*
  80        Messages found only in the virgin translator are added to the
  81        vernacular translator. Among these are all the context comments.
  82      */
  83      all = virginTor->messages();
  84  
  85      for ( it = all.begin(); it != all.end(); ++it ) {
  86      if ( !tor->contains((*it).context(), (*it).sourceText(),
  87                  (*it).comment()) ) {
  88          tor->insert( *it );
  89          if ( !QCString((*it).sourceText()).isEmpty() )
  90          neww++;
  91      }
  92      }
  93  
  94      /*
  95        The same-text heuristic handles cases where a message has an
  96        obsolete counterpart with a different context or comment.
  97      */
  98      applySameTextHeuristic( tor, verbose );
  99  
 100      /*
 101        The number heuristic handles cases where a message has an
 102        obsolete counterpart with mostly numbers differing in the
 103        source text.
 104      */
 105      applyNumberHeuristic( tor, verbose );
 106  
 107      qWarning( " %s: %d known, %d new and %d obsoleted messages",
 108                language.latin1(), known, neww, obsoleted );
 109  }


Généré le : Sat Feb 24 10:30:04 2007 par Balluche grâce à PHPXref 0.7