summaryrefslogtreecommitdiffstats
path: root/tools/linguist
diff options
context:
space:
mode:
authorWarwick Allison <warwick.allison@nokia.com>2009-11-27 00:09:00 (GMT)
committerWarwick Allison <warwick.allison@nokia.com>2009-11-27 00:09:00 (GMT)
commit1efae63bf7cba55526c91dcff3139d0a10885efc (patch)
treed07e1a5db7b2726bbc5d941da3ed97097820b8ca /tools/linguist
parent249bb31dc9fa12acff44ebf0effbdaedc43b5305 (diff)
parent41f1276392444b9e46b30f3537a8a63af6fffc9d (diff)
downloadQt-1efae63bf7cba55526c91dcff3139d0a10885efc.zip
Qt-1efae63bf7cba55526c91dcff3139d0a10885efc.tar.gz
Qt-1efae63bf7cba55526c91dcff3139d0a10885efc.tar.bz2
Merge branch '4.6' of git://scm.dev.nokia.troll.no/qt/qt into kinetic-declarativeui
Diffstat (limited to 'tools/linguist')
-rw-r--r--tools/linguist/lconvert/main.cpp6
-rw-r--r--tools/linguist/linguist/finddialog.cpp2
-rw-r--r--tools/linguist/linguist/mainwindow.cpp2
-rw-r--r--tools/linguist/linguist/messageeditor.cpp36
-rw-r--r--tools/linguist/linguist/phrasebookbox.cpp2
-rw-r--r--tools/linguist/lrelease/lrelease.pro7
-rw-r--r--tools/linguist/lupdate/cpp.cpp26
-rw-r--r--tools/linguist/lupdate/main.cpp16
-rw-r--r--tools/linguist/phrasebooks/french.qph36
-rw-r--r--tools/linguist/shared/translator.cpp11
-rw-r--r--tools/linguist/shared/translator.h7
11 files changed, 105 insertions, 46 deletions
diff --git a/tools/linguist/lconvert/main.cpp b/tools/linguist/lconvert/main.cpp
index 7807761..5f3de7b 100644
--- a/tools/linguist/lconvert/main.cpp
+++ b/tools/linguist/lconvert/main.cpp
@@ -46,6 +46,8 @@
#include <QtCore/QString>
#include <QtCore/QStringList>
+#include <iostream>
+
static int usage(const QStringList &args)
{
Q_UNUSED(args);
@@ -55,7 +57,7 @@ static int usage(const QStringList &args)
foreach (Translator::FileFormat format, Translator::registeredFileFormats())
loaders += line.arg(format.extension, -5).arg(format.description);
- qWarning("%s", qPrintable(QString(QLatin1String("\nUsage:\n"
+ std::cerr << qPrintable(QString(QLatin1String("\nUsage:\n"
" lconvert [options] <infile> [<infile>...]\n\n"
"lconvert is part of Qt's Linguist tool chain. It can be used as a\n"
"stand-alone tool to convert and filter translation data files.\n"
@@ -117,7 +119,7 @@ static int usage(const QStringList &args)
" 0 on success\n"
" 1 on command line parse failures\n"
" 2 on read failures\n"
- " 3 on write failures\n")).arg(loaders)));
+ " 3 on write failures\n")).arg(loaders));
return 1;
}
diff --git a/tools/linguist/linguist/finddialog.cpp b/tools/linguist/linguist/finddialog.cpp
index d49ffc5..7027264 100644
--- a/tools/linguist/linguist/finddialog.cpp
+++ b/tools/linguist/linguist/finddialog.cpp
@@ -57,7 +57,7 @@ FindDialog::FindDialog(QWidget *parent)
findNxt->setEnabled(false);
connect(findNxt, SIGNAL(clicked()), this, SLOT(emitFindNext()));
- connect(led, SIGNAL(textChanged(const QString &)), this, SLOT(verifyText(const QString &)));
+ connect(led, SIGNAL(textChanged(QString)), this, SLOT(verifyText(QString)));
led->setFocus();
}
diff --git a/tools/linguist/linguist/mainwindow.cpp b/tools/linguist/linguist/mainwindow.cpp
index 7f09a1c..5c3aaa1 100644
--- a/tools/linguist/linguist/mainwindow.cpp
+++ b/tools/linguist/linguist/mainwindow.cpp
@@ -473,7 +473,7 @@ MainWindow::MainWindow()
this, SLOT(updateTranslatorComment(QString)));
connect(m_findDialog, SIGNAL(findNext(QString,DataModel::FindLocation,bool,bool)),
this, SLOT(findNext(QString,DataModel::FindLocation,bool,bool)));
- connect(m_translateDialog, SIGNAL(requestMatchUpdate(bool &)), SLOT(updateTranslateHit(bool &)));
+ connect(m_translateDialog, SIGNAL(requestMatchUpdate(bool&)), SLOT(updateTranslateHit(bool&)));
connect(m_translateDialog, SIGNAL(activated(int)), SLOT(translate(int)));
QSize as(qApp->desktop()->size());
diff --git a/tools/linguist/linguist/messageeditor.cpp b/tools/linguist/linguist/messageeditor.cpp
index dedb3ee..a7cc636 100644
--- a/tools/linguist/linguist/messageeditor.cpp
+++ b/tools/linguist/linguist/messageeditor.cpp
@@ -148,14 +148,14 @@ void MessageEditor::setupEditorPage()
m_source = new FormWidget(tr("Source text"), false);
m_source->setHideWhenEmpty(true);
m_source->setWhatsThis(tr("This area shows the source text."));
- connect(m_source, SIGNAL(selectionChanged(QTextEdit *)),
- SLOT(selectionChanged(QTextEdit *)));
+ connect(m_source, SIGNAL(selectionChanged(QTextEdit*)),
+ SLOT(selectionChanged(QTextEdit*)));
m_pluralSource = new FormWidget(tr("Source text (Plural)"), false);
m_pluralSource->setHideWhenEmpty(true);
m_pluralSource->setWhatsThis(tr("This area shows the plural form of the source text."));
- connect(m_pluralSource, SIGNAL(selectionChanged(QTextEdit *)),
- SLOT(selectionChanged(QTextEdit *)));
+ connect(m_pluralSource, SIGNAL(selectionChanged(QTextEdit*)),
+ SLOT(selectionChanged(QTextEdit*)));
m_commentText = new FormWidget(tr("Developer comments"), false);
m_commentText->setHideWhenEmpty(true);
@@ -222,11 +222,11 @@ void MessageEditor::messageModelAppended()
ed.transCommentText->setWhatsThis(tr("Here you can enter comments for your own use."
" They have no effect on the translated applications.") );
ed.transCommentText->getEditor()->installEventFilter(this);
- connect(ed.transCommentText, SIGNAL(selectionChanged(QTextEdit *)),
- SLOT(selectionChanged(QTextEdit *)));
- connect(ed.transCommentText, SIGNAL(textChanged(QTextEdit *)),
- SLOT(emitTranslatorCommentChanged(QTextEdit *)));
- connect(ed.transCommentText, SIGNAL(textChanged(QTextEdit *)), SLOT(resetHoverSelection()));
+ connect(ed.transCommentText, SIGNAL(selectionChanged(QTextEdit*)),
+ SLOT(selectionChanged(QTextEdit*)));
+ connect(ed.transCommentText, SIGNAL(textChanged(QTextEdit*)),
+ SLOT(emitTranslatorCommentChanged(QTextEdit*)));
+ connect(ed.transCommentText, SIGNAL(textChanged(QTextEdit*)), SLOT(resetHoverSelection()));
connect(ed.transCommentText, SIGNAL(cursorPositionChanged()), SLOT(resetHoverSelection()));
fixTabOrder();
QBoxLayout *box = new QVBoxLayout(ed.container);
@@ -275,7 +275,7 @@ void MessageEditor::messageModelDeleted(int model)
void MessageEditor::addPluralForm(int model, const QString &label, bool writable)
{
FormMultiWidget *transEditor = new FormMultiWidget(label);
- connect(transEditor, SIGNAL(editorCreated(QTextEdit *)), SLOT(editorCreated(QTextEdit *)));
+ connect(transEditor, SIGNAL(editorCreated(QTextEdit*)), SLOT(editorCreated(QTextEdit*)));
transEditor->setEditingEnabled(writable);
transEditor->setHideWhenEmpty(!writable);
if (!m_editors[model].transTexts.isEmpty())
@@ -284,11 +284,11 @@ void MessageEditor::addPluralForm(int model, const QString &label, bool writable
static_cast<QBoxLayout *>(m_editors[model].container->layout())->insertWidget(
m_editors[model].transTexts.count(), transEditor);
- connect(transEditor, SIGNAL(selectionChanged(QTextEdit *)),
- SLOT(selectionChanged(QTextEdit *)));
- connect(transEditor, SIGNAL(textChanged(QTextEdit *)),
- SLOT(emitTranslationChanged(QTextEdit *)));
- connect(transEditor, SIGNAL(textChanged(QTextEdit *)), SLOT(resetHoverSelection()));
+ connect(transEditor, SIGNAL(selectionChanged(QTextEdit*)),
+ SLOT(selectionChanged(QTextEdit*)));
+ connect(transEditor, SIGNAL(textChanged(QTextEdit*)),
+ SLOT(emitTranslationChanged(QTextEdit*)));
+ connect(transEditor, SIGNAL(textChanged(QTextEdit*)), SLOT(resetHoverSelection()));
connect(transEditor, SIGNAL(cursorPositionChanged()), SLOT(resetHoverSelection()));
m_editors[model].transTexts << transEditor;
@@ -407,10 +407,12 @@ QTextEdit *MessageEditor::activeTranslation() const
{
if (m_currentNumerus < 0)
return 0;
- foreach (QTextEdit *te, m_editors[m_currentModel].transTexts[m_currentNumerus]->getEditors())
+ const QList<FormatTextEdit *> &editors =
+ m_editors[m_currentModel].transTexts[m_currentNumerus]->getEditors();
+ foreach (QTextEdit *te, editors)
if (te->hasFocus())
return te;
- return 0; // This cannot happen
+ return editors.first();
}
QTextEdit *MessageEditor::activeOr1stTranslation() const
diff --git a/tools/linguist/linguist/phrasebookbox.cpp b/tools/linguist/linguist/phrasebookbox.cpp
index 57518c1..fd423d4 100644
--- a/tools/linguist/linguist/phrasebookbox.cpp
+++ b/tools/linguist/linguist/phrasebookbox.cpp
@@ -87,7 +87,7 @@ PhraseBookBox::PhraseBookBox(PhraseBook *phraseBook, QWidget *parent)
this, SLOT(targetChanged(QString)));
connect(definitionLed, SIGNAL(textChanged(QString)),
this, SLOT(definitionChanged(QString)));
- connect(phraseList->selectionModel(), SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)),
+ connect(phraseList->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),
this, SLOT(selectionChanged()));
connect(newBut, SIGNAL(clicked()), this, SLOT(newPhrase()));
connect(removeBut, SIGNAL(clicked()), this, SLOT(removePhrase()));
diff --git a/tools/linguist/lrelease/lrelease.pro b/tools/linguist/lrelease/lrelease.pro
index e4c18ee..b13c03e 100644
--- a/tools/linguist/lrelease/lrelease.pro
+++ b/tools/linguist/lrelease/lrelease.pro
@@ -5,6 +5,13 @@ DESTDIR = ../../../bin
DEFINES += QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII
SOURCES += main.cpp
+INCLUDEPATH += $$QT_BUILD_TREE/src/corelib/global # qlibraryinfo.cpp includes qconfig.cpp
+SOURCES += \
+ $$QT_SOURCE_TREE/src/corelib/global/qlibraryinfo.cpp \
+ $$QT_SOURCE_TREE/src/corelib/io/qsettings.cpp
+win32:SOURCES += $$QT_SOURCE_TREE/src/corelib/io/qsettings_win.cpp
+macx:SOURCES += $$QT_SOURCE_TREE/src/corelib/io/qsettings_mac.cpp
+
include(../../../src/tools/bootstrap/bootstrap.pri)
include(../shared/formats.pri)
include(../shared/proparser.pri)
diff --git a/tools/linguist/lupdate/cpp.cpp b/tools/linguist/lupdate/cpp.cpp
index 443abd0..857233e 100644
--- a/tools/linguist/lupdate/cpp.cpp
+++ b/tools/linguist/lupdate/cpp.cpp
@@ -306,7 +306,6 @@ private:
// the string to read from and current position in the string
QTextCodec *yySourceCodec;
- bool yySourceIsUnicode;
QString yyInStr;
const ushort *yyInPtr;
@@ -353,7 +352,6 @@ void CppParser::setInput(const QString &in)
yyInStr = in;
yyFileName = QString();
yySourceCodec = 0;
- yySourceIsUnicode = true;
yyForceUtf8 = true;
}
@@ -362,7 +360,6 @@ void CppParser::setInput(QTextStream &ts, const QString &fileName)
yyInStr = ts.readAll();
yyFileName = fileName;
yySourceCodec = ts.codec();
- yySourceIsUnicode = yySourceCodec->name().startsWith("UTF-");
yyForceUtf8 = false;
}
@@ -1430,24 +1427,24 @@ QString CppParser::transcode(const QString &str, bool utf8)
{
static const char tab[] = "abfnrtv";
static const char backTab[] = "\a\b\f\n\r\t\v";
- const QString in = (!utf8 || yySourceIsUnicode)
- ? str : QString::fromUtf8(yySourceCodec->fromUnicode(str).data());
- QString out;
+ // This function has to convert back to bytes, as C's \0* sequences work at that level.
+ const QByteArray in = yyForceUtf8 ? str.toUtf8() : tor->codec()->fromUnicode(str);
+ QByteArray out;
out.reserve(in.length());
for (int i = 0; i < in.length();) {
- ushort c = in[i++].unicode();
+ uchar c = in[i++];
if (c == '\\') {
if (i >= in.length())
break;
- c = in[i++].unicode();
+ c = in[i++];
if (c == '\n')
continue;
if (c == 'x') {
QByteArray hex;
- while (i < in.length() && isxdigit((c = in[i].unicode()))) {
+ while (i < in.length() && isxdigit((c = in[i]))) {
hex += c;
i++;
}
@@ -1456,7 +1453,7 @@ QString CppParser::transcode(const QString &str, bool utf8)
QByteArray oct;
int n = 0;
oct += c;
- while (n < 2 && i < in.length() && (c = in[i].unicode()) >= '0' && c < '8') {
+ while (n < 2 && i < in.length() && (c = in[i]) >= '0' && c < '8') {
i++;
n++;
oct += c;
@@ -1464,13 +1461,14 @@ QString CppParser::transcode(const QString &str, bool utf8)
out += oct.toUInt(0, 8);
} else {
const char *p = strchr(tab, c);
- out += QChar(QLatin1Char(!p ? c : backTab[p - tab]));
+ out += !p ? c : backTab[p - tab];
}
} else {
out += c;
}
}
- return out;
+ return (utf8 || yyForceUtf8) ? QString::fromUtf8(out.constData(), out.length())
+ : tor->codec()->toUnicode(out);
}
void CppParser::recordMessage(
@@ -2150,9 +2148,9 @@ void loadCPP(Translator &translator, const QStringList &filenames, ConversionDat
QTextStream ts(&file);
ts.setCodec(codec);
ts.setAutoDetectUnicode(true);
- if (ts.codec()->name() == "UTF-16")
- translator.setCodecName("System");
parser.setInput(ts, filename);
+ if (cd.m_outputCodec.isEmpty() && ts.codec()->name() == "UTF-16")
+ translator.setCodecName("System");
Translator *tor = new Translator;
tor->setCodecName(translator.codecName());
parser.setTranslator(tor);
diff --git a/tools/linguist/lupdate/main.cpp b/tools/linguist/lupdate/main.cpp
index af40616..d76350d 100644
--- a/tools/linguist/lupdate/main.cpp
+++ b/tools/linguist/lupdate/main.cpp
@@ -54,13 +54,20 @@
#include <QtCore/QStringList>
#include <QtCore/QTextCodec>
+#include <iostream>
+
static QString m_defaultExtensions;
-static void printOut(const QString & out)
+static void printErr(const QString & out)
{
qWarning("%s", qPrintable(out));
}
+static void printOut(const QString & out)
+{
+ std::cerr << qPrintable(out);
+}
+
static void recursiveFileInfoList(const QDir &dir,
const QSet<QString> &nameFilters, QDir::Filters filter,
QFileInfoList *fileinfolist)
@@ -137,7 +144,7 @@ static void updateTsFiles(const Translator &fetchedTor, const QStringList &tsFil
cd.m_sortContexts = !(options & NoSort);
if (QFile(fileName).exists()) {
if (!tor.load(fileName, cd, QLatin1String("auto"))) {
- printOut(cd.error());
+ printErr(cd.error());
*fail = true;
continue;
}
@@ -197,11 +204,11 @@ static void updateTsFiles(const Translator &fetchedTor, const QStringList &tsFil
out.normalizeTranslations(cd);
if (!cd.errors().isEmpty()) {
- printOut(cd.error());
+ printErr(cd.error());
cd.clearErrors();
}
if (!out.save(fileName, cd, QLatin1String("auto"))) {
- printOut(cd.error());
+ printErr(cd.error());
*fail = true;
}
}
@@ -495,6 +502,7 @@ int main(int argc, char **argv)
if (!tmp.isEmpty() && !tmp.first().isEmpty()) {
codecForTr = tmp.first().toLatin1();
fetchedTor.setCodecName(codecForTr);
+ cd.m_outputCodec = codecForTr;
}
tmp = variables.value("CODECFORSRC");
if (!tmp.isEmpty() && !tmp.first().isEmpty()) {
diff --git a/tools/linguist/phrasebooks/french.qph b/tools/linguist/phrasebooks/french.qph
index d710abd..9e1a580 100644
--- a/tools/linguist/phrasebooks/french.qph
+++ b/tools/linguist/phrasebooks/french.qph
@@ -1402,4 +1402,40 @@
<source>&amp;Redo</source>
<target>&amp;Rétablir</target>
</phrase>
+<phrase>
+ <source>Edit</source>
+ <target>Éditer</target>
+</phrase>
+<phrase>
+ <source>PATH:</source>
+ <target>PATH :</target>
+</phrase>
+<phrase>
+ <source>Change:</source>
+ <target>Modification :</target>
+</phrase>
+<phrase>
+ <source>Edit...</source>
+ <target>Modifier...</target>
+</phrase>
+<phrase>
+ <source>&amp;Username:</source>
+ <target>&amp;Utilisateur :</target>
+</phrase>
+<phrase>
+ <source>Link</source>
+ <target>Lien</target>
+</phrase>
+<phrase>
+ <source>Paste:</source>
+ <target>Collage :</target>
+</phrase>
+<phrase>
+ <source>Label</source>
+ <target>Libellé</target>
+</phrase>
+<phrase>
+ <source>&amp;Debug</source>
+ <target>&amp;Déboguer</target>
+</phrase>
</QPH>
diff --git a/tools/linguist/shared/translator.cpp b/tools/linguist/shared/translator.cpp
index 05fc6e5..8a071d3 100644
--- a/tools/linguist/shared/translator.cpp
+++ b/tools/linguist/shared/translator.cpp
@@ -67,7 +67,7 @@ QString QObject::tr(const char *sourceText, const char *, int n)
#endif
Translator::Translator() :
- m_codecName("ISO-8859-1"),
+ m_codec(QTextCodec::codecForName("ISO-8859-1")),
m_locationsType(AbsoluteLocations)
{
}
@@ -713,12 +713,17 @@ void Translator::setCodecName(const QByteArray &name)
if (!codec) {
if (!name.isEmpty())
qWarning("No QTextCodec for %s available. Using Latin1\n", name.constData());
- m_codecName = "ISO-8859-1";
+ m_codec = QTextCodec::codecForName("ISO-8859-1");
} else {
- m_codecName = codec->name();
+ m_codec = codec;
}
}
+QByteArray Translator::codecName() const
+{
+ return m_codec->name();
+}
+
void Translator::dump() const
{
for (int i = 0; i != messageCount(); ++i)
diff --git a/tools/linguist/shared/translator.h b/tools/linguist/shared/translator.h
index f29317b..353cf9d 100644
--- a/tools/linguist/shared/translator.h
+++ b/tools/linguist/shared/translator.h
@@ -97,7 +97,7 @@ public:
public:
QString m_defaultContext;
QByteArray m_codecForSource; // CPP, PO & QM specific
- QByteArray m_outputCodec; // PO specific
+ QByteArray m_outputCodec; // CPP & PO specific
QString m_unTrPrefix; // QM specific
QString m_sourceFileName;
QString m_targetFileName;
@@ -151,7 +151,8 @@ public:
void reportDuplicates(const Duplicates &dupes, const QString &fileName, bool verbose);
void setCodecName(const QByteArray &name);
- QByteArray codecName() const { return m_codecName; }
+ QByteArray codecName() const;
+ QTextCodec *codec() const { return m_codec; }
QString languageCode() const { return m_language; }
QString sourceLanguageCode() const { return m_sourceLanguage; }
@@ -211,7 +212,7 @@ private:
typedef QList<TranslatorMessage> TMM; // int stores the sequence position.
TMM m_messages;
- QByteArray m_codecName;
+ QTextCodec *m_codec;
LocationsType m_locationsType;
// A string beginning with a 2 or 3 letter language code (ISO 639-1