diff options
Diffstat (limited to 'src/common-lib/utilities.cpp')
-rw-r--r-- | src/common-lib/utilities.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/common-lib/utilities.cpp b/src/common-lib/utilities.cpp index 811365d4..b5b5b4e5 100644 --- a/src/common-lib/utilities.cpp +++ b/src/common-lib/utilities.cpp @@ -337,4 +337,20 @@ void recursiveMergeVariantMap(QVariantMap &into, const QVariantMap &from) recursiveMergeMap(&into, from); } +QString translateFromMap(const QMap<QString, QString> &languageToName, const QString &defaultName) +{ + if (!languageToName.isEmpty()) { + QString name = languageToName.value(QLocale::system().name()); //TODO: language changes + if (name.isNull()) + name = languageToName.value(qSL("en")); + if (name.isNull()) + name = languageToName.value(qSL("en_US")); + if (name.isNull()) + name = languageToName.first(); + return name; + } else { + return defaultName; + } +} + QT_END_NAMESPACE_AM |