From 3b8c67a07acd049035ac67c6ff981939f357473c Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Wed, 30 Sep 2009 17:03:59 +0200 Subject: Fix locale encoding in XLIFF files xlf uses xx-YY notation instead of xx_YY Reviewed-by: ossi --- tools/linguist/shared/xliff.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'tools/linguist/shared') diff --git a/tools/linguist/shared/xliff.cpp b/tools/linguist/shared/xliff.cpp index b0c7546460..696c930b13 100644 --- a/tools/linguist/shared/xliff.cpp +++ b/tools/linguist/shared/xliff.cpp @@ -498,7 +498,9 @@ bool XLIFFHandler::startElement(const QString& namespaceURI, } else if (localName == QLatin1String("file")) { m_fileName = atts.value(QLatin1String("original")); m_language = atts.value(QLatin1String("target-language")); + m_language.replace(QLatin1Char('-'), QLatin1Char('_')); m_sourceLanguage = atts.value(QLatin1String("source-language")); + m_sourceLanguage.replace(QLatin1Char('-'), QLatin1Char('_')); } else if (localName == QLatin1String("group")) { if (atts.value(QLatin1String("restype")) == QLatin1String(restypeContext)) { m_context = atts.value(QLatin1String("resname")); @@ -768,14 +770,19 @@ bool saveXLIFF(const Translator &translator, QIODevice &dev, ConversionData &cd) << "\" xmlns:trolltech=\"" << TrollTsNamespaceURI << "\">\n"; ++indent; writeExtras(ts, indent, translator.extras(), drops); + QString sourceLanguageCode = translator.sourceLanguageCode(); + if (sourceLanguageCode.isEmpty() || sourceLanguageCode == QLatin1String("C")) + sourceLanguageCode = QLatin1String("en"); + else + sourceLanguageCode.replace(QLatin1Char('_'), QLatin1Char('-')); + QString languageCode = translator.languageCode(); + languageCode.replace(QLatin1Char('_'), QLatin1Char('-')); foreach (const QString &fn, fileOrder) { writeIndent(ts, indent); ts << "first()) << "\"" - << " source-language=\"" - << (translator.sourceLanguageCode().isEmpty() ? - QByteArray("en") : translator.sourceLanguageCode().toLatin1()) << "\"" - << " target-language=\"" << translator.languageCode() << "\"" + << " source-language=\"" << sourceLanguageCode.toLatin1() << "\"" + << " target-language=\"" << languageCode.toLatin1() << "\"" << ">\n"; ++indent; -- cgit v1.2.3