summaryrefslogtreecommitdiffstats
path: root/tools/linguist/shared/qph.cpp
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>2009-11-25 19:53:21 (GMT)
committerOswald Buddenhagen <oswald.buddenhagen@nokia.com>2009-11-25 19:54:10 (GMT)
commit729d01352f7c6165228eab9e32d52becbb4258a5 (patch)
treec1462baac2a31216d644c35ec9760598f9bfa168 /tools/linguist/shared/qph.cpp
parent9554e641af877ee08eeae9adae4acf4d8b1d198d (diff)
downloadQt-729d01352f7c6165228eab9e32d52becbb4258a5.zip
Qt-729d01352f7c6165228eab9e32d52becbb4258a5.tar.gz
Qt-729d01352f7c6165228eab9e32d52becbb4258a5.tar.bz2
make qph use language attributes
Diffstat (limited to 'tools/linguist/shared/qph.cpp')
-rw-r--r--tools/linguist/shared/qph.cpp23
1 files changed, 18 insertions, 5 deletions
diff --git a/tools/linguist/shared/qph.cpp b/tools/linguist/shared/qph.cpp
index fb4fee9..32bdabb 100644
--- a/tools/linguist/shared/qph.cpp
+++ b/tools/linguist/shared/qph.cpp
@@ -81,14 +81,20 @@ bool QPHReader::read(Translator &translator)
while (!atEnd()) {
readNext();
if (isStartElement()) {
- if (name() == QLatin1String("source"))
+ if (name() == QLatin1String("source")) {
m_currentField = SourceField;
- else if (name() == QLatin1String("target"))
+ } else if (name() == QLatin1String("target")) {
m_currentField = TargetField;
- else if (name() == QLatin1String("definition"))
+ } else if (name() == QLatin1String("definition")) {
m_currentField = DefinitionField;
- else
+ } else {
m_currentField = NoField;
+ if (name() == QLatin1String("QPH")) {
+ QXmlStreamAttributes atts = attributes();
+ translator.setLanguageCode(atts.value(QLatin1String("language")).toString());
+ translator.setSourceLanguageCode(atts.value(QLatin1String("sourcelanguage")).toString());
+ }
+ }
} else if (isWhiteSpace()) {
// ignore these
} else if (isCharacters()) {
@@ -157,7 +163,14 @@ static bool saveQPH(const Translator &translator, QIODevice &dev, ConversionData
{
QTextStream t(&dev);
t.setCodec(QTextCodec::codecForName("UTF-8"));
- t << "<!DOCTYPE QPH>\n<QPH>\n";
+ t << "<!DOCTYPE QPH>\n<QPH";
+ QString languageCode = translator.languageCode();
+ if (!languageCode.isEmpty() && languageCode != QLatin1String("C"))
+ t << " language=\"" << languageCode << "\"";
+ languageCode = translator.sourceLanguageCode();
+ if (!languageCode.isEmpty() && languageCode != QLatin1String("C"))
+ t << " sourcelanguage=\"" << languageCode << "\"";
+ t << ">\n";
foreach (const TranslatorMessage &msg, translator.messages()) {
t << "<phrase>\n";
t << " <source>" << protect(msg.sourceText()) << "</source>\n";