summaryrefslogtreecommitdiff
path: root/development/translation/opie-lupdate/numberh.cpp
authorzecke <zecke>2004-01-09 19:13:35 (UTC)
committer zecke <zecke>2004-01-09 19:13:35 (UTC)
commit56bb9961db1158250bbfe971f4556b56c0bd6581 (patch) (side-by-side diff)
treea4f40da98f695b5aadd845b68aaab41ac3d81826 /development/translation/opie-lupdate/numberh.cpp
parent6875988077013544246ae0df7cc2e5d538a7f152 (diff)
downloadopie-56bb9961db1158250bbfe971f4556b56c0bd6581.zip
opie-56bb9961db1158250bbfe971f4556b56c0bd6581.tar.gz
opie-56bb9961db1158250bbfe971f4556b56c0bd6581.tar.bz2
Update lupdate and shared to Qt3.3 qt-copy sources
Some special replacement for $$(OPIEDIR) to make ar_* happy
Diffstat (limited to 'development/translation/opie-lupdate/numberh.cpp') (more/less context) (show whitespace changes)
-rw-r--r--development/translation/opie-lupdate/numberh.cpp24
1 files changed, 15 insertions, 9 deletions
diff --git a/development/translation/opie-lupdate/numberh.cpp b/development/translation/opie-lupdate/numberh.cpp
index f7b7bf8..2f12c3d 100644
--- a/development/translation/opie-lupdate/numberh.cpp
+++ b/development/translation/opie-lupdate/numberh.cpp
@@ -1,72 +1,78 @@
/**********************************************************************
** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
**
** This file is part of Qt Linguist.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
+** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
+** licenses may use this file in accordance with the Qt Commercial License
+** Agreement provided with the Software.
+**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
+** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
+** information about Qt Commercial License Agreements.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include <metatranslator.h>
#include <qmemarray.h>
#include <qcstring.h>
#include <qmap.h>
#include <qstringlist.h>
#include <ctype.h>
typedef QMap<QCString, MetaTranslatorMessage> TMM;
typedef QValueList<MetaTranslatorMessage> TML;
static bool isDigitFriendly( int c )
{
- return ispunct( c ) || isspace( c );
+ return ispunct((uchar)c) || isspace((uchar)c);
}
static int numberLength( const char *s )
{
int i = 0;
- if ( isdigit(s[0]) ) {
+ if ( isdigit((uchar)s[0]) ) {
do {
i++;
- } while ( isdigit(s[i]) ||
+ } while (isdigit((uchar)s[i]) ||
(isDigitFriendly(s[i]) &&
- (isdigit(s[i + 1]) ||
- (isDigitFriendly(s[i + 1]) && isdigit(s[i + 2])))) );
+ (isdigit((uchar)s[i + 1]) ||
+ (isDigitFriendly(s[i + 1]) && isdigit((uchar)s[i + 2])))));
}
return i;
}
/*
Returns a version of 'key' where all numbers have been replaced by zeroes. If
there were none, returns "".
*/
static QCString zeroKey( const char *key )
{
QCString zeroed( strlen(key) + 1 );
char *z = zeroed.data();
int i = 0, j = 0;
int len;
bool metSomething = FALSE;
while ( key[i] != '\0' ) {
len = numberLength( key + i );
if ( len > 0 ) {
i += len;
z[j++] = '0';
metSomething = TRUE;
} else {
z[j++] = key[i++];
@@ -190,46 +196,46 @@ static QString translationAttempt( const QString& oldTranslation,
}
}
return attempt;
}
/*
Augments a MetaTranslator with translations easily derived from
similar existing (probably obsolete) translations.
For example, if "TeX 3.0" is translated as "XeT 3.0" and "TeX 3.1"
has no translation, "XeT 3.1" is added to the translator and is
marked Unfinished.
*/
void applyNumberHeuristic( MetaTranslator *tor, bool verbose )
{
TMM translated, untranslated;
TMM::Iterator t, u;
TML all = tor->messages();
TML::Iterator it;
int inserted = 0;
for ( it = all.begin(); it != all.end(); ++it ) {
if ( (*it).type() == MetaTranslatorMessage::Unfinished ) {
if ( (*it).translation().isEmpty() )
- untranslated.insert( zeroKey((*it).sourceText()), *it );
+ untranslated.insert(QCString((*it).context()) + "\n" + (*it).sourceText() + "\n"
+ + (*it).comment(), *it);
} else if ( !(*it).translation().isEmpty() ) {
translated.insert( zeroKey((*it).sourceText()), *it );
}
}
for ( u = untranslated.begin(); u != untranslated.end(); ++u ) {
- t = translated.find( u.key() );
+ t = translated.find( zeroKey((*u).sourceText()) );
if ( t != translated.end() && !t.key().isEmpty() &&
qstrcmp((*t).sourceText(), (*u).sourceText()) != 0 ) {
MetaTranslatorMessage m( *u );
- m.setTranslation( translationAttempt((*t).translation(),
- (*t).sourceText(),
+ m.setTranslation(translationAttempt((*t).translation(), (*t).sourceText(),
(*u).sourceText()) );
tor->insert( m );
inserted++;
}
}
if ( verbose && inserted != 0 )
fprintf( stderr, " number heuristic provided %d translation%s\n",
inserted, inserted == 1 ? "" : "s" );
}