| 1 |
// Copyright (C) 2016 Klarälvdalens Datakonsult AB, a KDAB Group company, [email protected], author Stephen Kelly <[email protected]> |
| 2 |
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 |
|
| 4 |
#include <QCoreApplication> |
| 5 |
#include <QLocale> |
| 6 |
#include <QTranslator> |
| 7 |
|
| 8 |
#include "some_include.h" |
| 9 |
|
| 10 |
int main(int argc, char **argv) |
| 11 |
{ |
| 12 |
QCoreApplication app(argc, argv); |
| 13 |
QTranslator *myappTranslator = new QTranslator; |
| 14 |
|
| 15 |
QLocale::setDefault(QLocale("de")); |
| 16 |
|
| 17 |
if (!myappTranslator->load(QLocale(), "myobject", "_", qApp->applicationDirPath())) |
| 18 |
qFatal("Could not load translation file!"); |
| 19 |
|
| 20 |
app.installTranslator(myappTranslator); |
| 21 |
|
| 22 |
QString text = QCoreApplication::translate("main", "Hello, world!"); |
| 23 |
if (text != QLatin1String("Hallo, Welt!")) |
| 24 |
qFatal("Translation not found!"); |
| 25 |
|
| 26 |
std::fprintf(stdout, "%s\n", qPrintable(text)); |
| 27 |
return 0; |
| 28 |
} |