48 #include <QtCore/QRegExp> |
48 #include <QtCore/QRegExp> |
49 #include <QtCore/QStack> |
49 #include <QtCore/QStack> |
50 #include <QtCore/QStack> |
50 #include <QtCore/QStack> |
51 #include <QtCore/QString> |
51 #include <QtCore/QString> |
52 #include <QtCore/QTextCodec> |
52 #include <QtCore/QTextCodec> |
|
53 #include <QtCore/QCoreApplication> |
53 |
54 |
54 #include <iostream> |
55 #include <iostream> |
55 |
56 |
56 #include <ctype.h> |
57 #include <ctype.h> |
57 |
58 |
58 QT_BEGIN_NAMESPACE |
59 QT_BEGIN_NAMESPACE |
|
60 |
|
61 class LU { |
|
62 Q_DECLARE_TR_FUNCTIONS(LUpdate) |
|
63 }; |
59 |
64 |
60 enum { Tok_Eof, Tok_class, Tok_return, Tok_tr, |
65 enum { Tok_Eof, Tok_class, Tok_return, Tok_tr, |
61 Tok_translate, Tok_Ident, Tok_Package, |
66 Tok_translate, Tok_Ident, Tok_Package, |
62 Tok_Comment, Tok_String, Tok_Colon, Tok_Dot, |
67 Tok_Comment, Tok_String, Tok_Colon, Tok_Dot, |
63 Tok_LeftBrace, Tok_RightBrace, Tok_LeftParen, |
68 Tok_LeftBrace, Tok_RightBrace, Tok_LeftParen, |
366 while ( yyTok == Tok_Plus ) { |
371 while ( yyTok == Tok_Plus ) { |
367 yyTok = getToken(); |
372 yyTok = getToken(); |
368 if (yyTok == Tok_String) |
373 if (yyTok == Tok_String) |
369 s += yyString; |
374 s += yyString; |
370 else { |
375 else { |
371 yyMsg() << "String used in translation can contain only literals" |
376 yyMsg() << qPrintable(LU::tr( |
372 " concatenated with other literals, not expressions or numbers.\n"; |
377 "String used in translation can contain only literals" |
|
378 " concatenated with other literals, not expressions or numbers.\n")); |
373 return false; |
379 return false; |
374 } |
380 } |
375 yyTok = getToken(); |
381 yyTok = getToken(); |
376 } |
382 } |
377 return true; |
383 return true; |
475 yyTok = getToken(); |
481 yyTok = getToken(); |
476 if(yyTok == Tok_Ident) { |
482 if(yyTok == Tok_Ident) { |
477 yyScope.push(new Scope(yyIdent, Scope::Clazz, yyLineNo)); |
483 yyScope.push(new Scope(yyIdent, Scope::Clazz, yyLineNo)); |
478 } |
484 } |
479 else { |
485 else { |
480 yyMsg() << "'class' must be followed by a class name.\n"; |
486 yyMsg() << qPrintable(LU::tr("'class' must be followed by a class name.\n")); |
481 break; |
487 break; |
482 } |
488 } |
483 while (!match(Tok_LeftBrace)) { |
489 while (!match(Tok_LeftBrace)) { |
484 yyTok = getToken(); |
490 yyTok = getToken(); |
485 } |
491 } |
589 yyTok = getToken(); |
595 yyTok = getToken(); |
590 } |
596 } |
591 } |
597 } |
592 |
598 |
593 if ( !yyScope.isEmpty() ) |
599 if ( !yyScope.isEmpty() ) |
594 yyMsg(yyScope.top()->line) << "Unbalanced opening brace.\n"; |
600 yyMsg(yyScope.top()->line) << qPrintable(LU::tr("Unbalanced opening brace.\n")); |
595 else if ( yyParenDepth != 0 ) |
601 else if ( yyParenDepth != 0 ) |
596 yyMsg(yyParenLineNo) << "Unbalanced opening parenthesis.\n"; |
602 yyMsg(yyParenLineNo) << qPrintable(LU::tr("Unbalanced opening parenthesis.\n")); |
597 } |
603 } |
598 |
604 |
599 |
605 |
600 bool loadJava(Translator &translator, const QString &filename, ConversionData &cd) |
606 bool loadJava(Translator &translator, const QString &filename, ConversionData &cd) |
601 { |
607 { |
602 QFile file(filename); |
608 QFile file(filename); |
603 if (!file.open(QIODevice::ReadOnly)) { |
609 if (!file.open(QIODevice::ReadOnly)) { |
604 cd.appendError(QString::fromLatin1("Cannot open %1: %2") |
610 cd.appendError(LU::tr("Cannot open %1: %2").arg(filename, file.errorString())); |
605 .arg(filename, file.errorString())); |
|
606 return false; |
611 return false; |
607 } |
612 } |
608 |
613 |
609 yyDefaultContext = cd.m_defaultContext; |
614 yyDefaultContext = cd.m_defaultContext; |
610 yyInPos = -1; |
615 yyInPos = -1; |