Diffstat (limited to 'development/translation/opie-lupdate') (more/less context) (show whitespace changes)
-rw-r--r-- | development/translation/opie-lupdate/fetchtr.cpp | 55 | ||||
-rw-r--r-- | development/translation/opie-lupdate/main.cpp | 11 | ||||
-rw-r--r-- | development/translation/opie-lupdate/merge.cpp | 6 | ||||
-rw-r--r-- | development/translation/opie-lupdate/numberh.cpp | 24 | ||||
-rw-r--r-- | development/translation/opie-lupdate/sametexth.cpp | 6 |
5 files changed, 82 insertions, 20 deletions
diff --git a/development/translation/opie-lupdate/fetchtr.cpp b/development/translation/opie-lupdate/fetchtr.cpp index d1f5881..a137628 100644 --- a/development/translation/opie-lupdate/fetchtr.cpp +++ b/development/translation/opie-lupdate/fetchtr.cpp @@ -9,8 +9,14 @@ ** 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 @@ -81,8 +87,11 @@ static char yyString[16384]; static size_t yyStringLen; static QValueStack<int> yySavedBraceDepth; +static QValueStack<int> yySavedParenDepth; static int yyBraceDepth; static int yyParenDepth; static int yyLineNo; static int yyCurLineNo; +static int yyBraceLineNo; +static int yyParenLineNo; // the file to read from (if reading from a file) @@ -120,7 +129,10 @@ static void startTokenizer( const char *fileName, int (*getCharFunc)() ) yyCh = getChar(); yySavedBraceDepth.clear(); + yySavedParenDepth.clear(); yyBraceDepth = 0; yyParenDepth = 0; yyCurLineNo = 1; + yyBraceLineNo = 1; + yyParenLineNo = 1; } @@ -165,4 +177,17 @@ static int getToken() return Tok_class; break; + case 'f': + /* + QTranslator::findMessage() has the same parameters as + QApplication::translate(). + */ + if ( strcmp(yyIdent + 1, "indMessage") == 0 ) + return Tok_translate; + break; + case 'i': + /* FOR KDE APPS */ + if ( strcmp( yyIdent + 1, "8n") == 0 ) + return Tok_translate; + break; case 'n': if ( strcmp(yyIdent + 1, "amespace") == 0 ) @@ -177,7 +202,4 @@ static int getToken() return Tok_class; break; - case 'i': - if( strcmp(yyIdent + 1, "18n") == 0 ) - return Tok_tr; case 't': if ( strcmp(yyIdent + 1, "r") == 0 ) { @@ -223,4 +245,5 @@ static int getToken() // if, ifdef, ifndef yySavedBraceDepth.push( yyBraceDepth ); + yySavedParenDepth.push( yyParenDepth ); } break; @@ -229,10 +252,14 @@ static int getToken() if ( yyCh == 'l' ) { // elif, else - if ( !yySavedBraceDepth.isEmpty() ) + if ( !yySavedBraceDepth.isEmpty() ) { yyBraceDepth = yySavedBraceDepth.top(); + yyParenDepth = yySavedParenDepth.top(); + } } else if ( yyCh == 'n' ) { // endif - if ( !yySavedBraceDepth.isEmpty() ) + if ( !yySavedBraceDepth.isEmpty() ) { yySavedBraceDepth.pop(); + yySavedParenDepth.pop(); + } } } @@ -357,16 +384,24 @@ static int getToken() break; case '{': + if (yyBraceDepth == 0) + yyBraceLineNo = yyCurLineNo; yyBraceDepth++; yyCh = getChar(); return Tok_LeftBrace; case '}': + if (yyBraceDepth == 0) + yyBraceLineNo = yyCurLineNo; yyBraceDepth--; yyCh = getChar(); return Tok_RightBrace; case '(': + if (yyParenDepth == 0) + yyParenLineNo = yyCurLineNo; yyParenDepth++; yyCh = getChar(); return Tok_LeftParen; case ')': + if (yyParenDepth == 0) + yyParenLineNo = yyCurLineNo; yyParenDepth--; yyCh = getChar(); @@ -622,12 +657,12 @@ static void parse( MetaTranslator *tor, const char *initialContext, if ( yyBraceDepth != 0 ) fprintf( stderr, - "%s: Unbalanced braces in C++ code (or abuse of the C++" + "%s:%d: Unbalanced braces in C++ code (or abuse of the C++" " preprocessor)\n", - (const char *) yyFileName ); - if ( yyParenDepth != 0 ) + (const char *)yyFileName, yyBraceLineNo ); + else if ( yyParenDepth != 0 ) fprintf( stderr, - "%s: Unbalanced parentheses in C++ code (or abuse of the C++" + "%s:%d: Unbalanced parentheses in C++ code (or abuse of the C++" " preprocessor)\n", - (const char *) yyFileName ); + (const char *)yyFileName, yyParenLineNo ); } diff --git a/development/translation/opie-lupdate/main.cpp b/development/translation/opie-lupdate/main.cpp index ce65e7a..bf16fd7 100644 --- a/development/translation/opie-lupdate/main.cpp +++ b/development/translation/opie-lupdate/main.cpp @@ -63,4 +63,13 @@ static void printUsage() } +/*static QString opie_escape( const QString& str ) { + QString ret = str.stripWhiteSpace(); + qWarning(ret); + if ( ret.startsWith("$$(OPIEDIR)") ) + ret = ret.replace("$$(OPIEDIR)", OPIE::self()->opieDir() ); + qWarning(ret); + return ret; + }*/ + static void updateTsFiles( const MetaTranslator& fetchedTor, const QString& opiedir, @@ -151,5 +160,5 @@ int main( int argc, char **argv ) isLib = FALSE; - QMap<QString, QString> tagMap = proFileTagMap( fullText ); + QMap<QString, QString> tagMap = proFileTagMap( fullText, OPIE::self()->opieDir() ); QMap<QString, QString>::Iterator it; diff --git a/development/translation/opie-lupdate/merge.cpp b/development/translation/opie-lupdate/merge.cpp index a96104e..3001d4b 100644 --- a/development/translation/opie-lupdate/merge.cpp +++ b/development/translation/opie-lupdate/merge.cpp @@ -9,8 +9,14 @@ ** 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 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 @@ -9,8 +9,14 @@ ** 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 @@ -33,5 +39,5 @@ typedef QValueList<MetaTranslatorMessage> TML; static bool isDigitFriendly( int c ) { - return ispunct( c ) || isspace( c ); + return ispunct((uchar)c) || isspace((uchar)c); } @@ -40,11 +46,11 @@ 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; @@ -212,5 +218,6 @@ void applyNumberHeuristic( MetaTranslator *tor, bool verbose ) 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 ); @@ -219,10 +226,9 @@ void applyNumberHeuristic( MetaTranslator *tor, bool verbose ) 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 ); diff --git a/development/translation/opie-lupdate/sametexth.cpp b/development/translation/opie-lupdate/sametexth.cpp index 574cfd5..80909b3 100644 --- a/development/translation/opie-lupdate/sametexth.cpp +++ b/development/translation/opie-lupdate/sametexth.cpp @@ -9,8 +9,14 @@ ** 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 |