forked from qt-creator/qt-creator
Added possibility to translate file types in open/save dialogs.
Merge-request: 900 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
This commit is contained in:
committed by
Oswald Buddenhagen
parent
6f6fafe1f9
commit
2c414f21a6
6
share/qtcreator/translations/extract-mimetypes.xq.in
Normal file
6
share/qtcreator/translations/extract-mimetypes.xq.in
Normal file
@@ -0,0 +1,6 @@
|
||||
let $files := ( $$MIMETYPES_FILES )
|
||||
let $prefix := string(\"QT_TRANSLATE_NOOP("MimeType", "\")
|
||||
let $suffix := concat(\"")\", codepoints-to-string(10))
|
||||
for $file in $files
|
||||
for $comment in doc($file)/*:mime-info/*:mime-type/*:comment
|
||||
return fn:concat($prefix, data($comment), $suffix)
|
||||
@@ -8,13 +8,25 @@ defineReplace(prependAll) {
|
||||
return($$result)
|
||||
}
|
||||
|
||||
XMLPATTERNS = $$targetPath($$[QT_INSTALL_BINS]/xmlpatterns)
|
||||
LUPDATE = $$targetPath($$[QT_INSTALL_BINS]/lupdate) -locations relative -no-ui-lines
|
||||
LRELEASE = $$targetPath($$[QT_INSTALL_BINS]/lrelease)
|
||||
|
||||
TRANSLATIONS = $$prependAll(LANGUAGES, $$PWD/qtcreator_,.ts)
|
||||
|
||||
contains(QT_VERSION, ^4\.[0-5]\..*):ts.commands = @echo This Qt version is too old for the ts target. Need Qt 4.6+.
|
||||
else:ts.commands = (cd $$IDE_SOURCE_TREE && $$LUPDATE src -ts $$TRANSLATIONS)
|
||||
MIME_TR_H = $$IDE_DATA_PATH/translations/mime_tr.h
|
||||
|
||||
contains(QT_VERSION, ^4\.[0-5]\..*) {
|
||||
ts.commands = @echo This Qt version is too old for the ts target. Need Qt 4.6+.
|
||||
} else {
|
||||
for(dir, $$list($$files($$IDE_SOURCE_TREE/src/plugins/*))):MIMETYPES_FILES += $$files($$dir/*.mimetypes.xml)
|
||||
MIMETYPES_FILES = \"$$join(MIMETYPES_FILES, \", \")\"
|
||||
QMAKE_SUBSTITUTES += extract-mimetypes.xq.in
|
||||
ts.commands += \
|
||||
$$XMLPATTERNS -output $$MIME_TR_H $$PWD/extract-mimetypes.xq && \
|
||||
(cd $$IDE_SOURCE_TREE && $$LUPDATE src $$MIME_TR_H -ts $$TRANSLATIONS) && \
|
||||
$$QMAKE_DEL_FILE $$MIME_TR_H
|
||||
}
|
||||
QMAKE_EXTRA_TARGETS += ts
|
||||
|
||||
TEMPLATE = app
|
||||
|
||||
@@ -717,7 +717,7 @@ bool BaseMimeTypeParser::parse(QIODevice *dev, const QString &fileName, QString
|
||||
case ParseComment: {
|
||||
// comments have locale attributes. We want the default, English one
|
||||
QString locale = reader.attributes().value(QLatin1String(localeAttributeC)).toString();
|
||||
const QString comment = reader.readElementText();
|
||||
const QString comment = QCoreApplication::translate("MimeType", reader.readElementText().toAscii());
|
||||
if (locale.isEmpty()) {
|
||||
data.comment = comment;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user