[wpdev-commits] wolfpack/tools/translationupdate fetchtrwp.cpp,1.2,1.3
Brought to you by:
rip,
thiagocorrea
From: Sebastian H. <dar...@us...> - 2004-10-05 16:25:06
|
Update of /cvsroot/wpdev/wolfpack/tools/translationupdate In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9967/tools/translationupdate Modified Files: fetchtrwp.cpp Log Message: updated python translations Index: fetchtrwp.cpp =================================================================== RCS file: /cvsroot/wpdev/wolfpack/tools/translationupdate/fetchtrwp.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** fetchtrwp.cpp 26 Sep 2004 12:45:54 -0000 1.2 --- fetchtrwp.cpp 5 Oct 2004 16:24:19 -0000 1.3 *************** *** 18,23 **** void fetchtr_py( const char* fileName, MetaTranslator* tor, const char* /*defaultContext*/, bool mustExist ) { ! static QRegExp matchtr("\\W(tr)\\s{0,1}\\("); ! static QRegExp stringDelimiter("(\"?|\'?)"); static QString context("@pythonscript"); --- 18,25 ---- void fetchtr_py( const char* fileName, MetaTranslator* tor, const char* /*defaultContext*/, bool mustExist ) { ! static QRegExp matchtr1("\\btr\\s{0,1}\\(\\s*\""); // Escaped by " ! static QRegExp matchtr2("\\btr\\s{0,1}\\(\\s*'"); // Escaped by " ! //static QRegExp stringDelimiter("(\"?|\'?)"); ! //static QRegExp stringDelimiter2("(\"?|\'?)"); static QString context("@pythonscript"); *************** *** 30,58 **** } QString content = QString( f.readAll() ); ! content.replace( QRegExp("#[^\n]*"), "" );; // remove single line comments int pos = 0; ! while ( ( pos = matchtr.search(content, pos) ) != -1 ) { ! QString message = content.mid(pos + matchtr.matchedLength()); ! int start = 0, end = 0; ! if ( ( start = stringDelimiter.search(message) ) == -1 ) ! { ! pos += matchtr.matchedLength(); ! continue; } ! QString startDelimiter = message.mid( start, stringDelimiter.matchedLength() ); ! end = message.find( startDelimiter, start + startDelimiter.length() ); ! if ( end == -1 ) ! { ! fprintf( stderr, "translationUpdate error: Open string in tr() '%s': %i\n", fileName, pos ); ! return; } ! ! QString source = message.mid( start + startDelimiter.length(), end - startDelimiter.length() ); ! if ( !source.isEmpty() ) ! tor->insert( MetaTranslatorMessage( context.utf8(), source.utf8(), QString(fileName).utf8(), QString::null, TRUE ) ); ! pos += QMAX( end, matchtr.matchedLength() ); } - } --- 32,131 ---- } QString content = QString( f.readAll() ); ! //content.replace( QRegExp("^#[^\n]*"), "" );; // remove single line comments ! ! int pos = 0; ! while ( ( pos = matchtr1.search(content, pos) ) != -1 ) { ! QString message = content.mid(pos + matchtr1.matchedLength()); ! QString realMessage; ! ! // Process the following string char-by-char ! unsigned int i = 0; ! while (i < message.length()) { ! QCharRef cref = message.at(i); ! ! // An escaped character ! if (cref == '\\' && i + 1 < message.length()) { ! // Get the next character ! QCharRef next = message.at(i+1); ! if (next == 'n') { ! realMessage.append('\n'); ! } else if ( next == '\t' ) { ! realMessage.append('\t'); ! } else if ( next == '\n' ) { ! // Skip escaped newlines ! } else { ! realMessage.append(next); ! } ! ! ++i; // Skip the next character ! // End of string ! } else if ( cref == '\n' ) { ! // This is an error, an unescaped newline breaks the string ! fprintf( stderr, "translationUpdate error: Open string in tr() '%s': %i\n", fileName, pos ); ! return; ! } else if ( cref == '"' ) { ! break; ! } else { ! realMessage.append(cref); ! } ! ! ++i; } ! ! if (!realMessage.isEmpty()) { ! tor->insert( MetaTranslatorMessage( context.utf8(), realMessage.utf8(), QString(fileName).utf8(), QString::null, TRUE ) ); } ! ! pos += matchtr1.matchedLength() + i; ! } ! ! pos = 0; ! while ( ( pos = matchtr2.search(content, pos) ) != -1 ) ! { ! QString message = content.mid(pos + matchtr2.matchedLength()); ! QString realMessage; ! ! // Process the following string char-by-char ! unsigned int i = 0; ! while (i < message.length()) { ! QCharRef cref = message.at(i); ! ! // An escaped character ! if (cref == '\\' && i + 1 < message.length()) { ! // Get the next character ! QCharRef next = message.at(i+1); ! if (next == 'n') { ! realMessage.append('\n'); ! } else if ( next == '\t' ) { ! realMessage.append('\t'); ! } else if ( next == '\n' ) { ! // Skip escaped newlines ! } else { ! realMessage.append(next); ! } ! ! ++i; // Skip the next character ! // End of string ! } else if ( cref == '\n' ) { ! // This is an error, an unescaped newline breaks the string ! fprintf( stderr, "translationUpdate error: Open string in tr() '%s': %i\n", fileName, pos ); ! return; ! } else if ( cref == '\'' ) { ! break; ! } else { ! realMessage.append(cref); ! } ! ! ++i; ! } ! ! if (!realMessage.isEmpty()) { ! tor->insert( MetaTranslatorMessage( context.utf8(), realMessage.utf8(), QString(fileName).utf8(), QString::null, TRUE ) ); ! } ! ! pos += matchtr2.matchedLength() + i; } } |