From: Soeren Apel Date: Thu, 2 Jul 2020 19:48:34 +0000 (+0200) Subject: Include translations and editors in about dialog X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=c8e2f09bf04bd3cab27b6152bcd92c7a85af424f;p=pulseview.git Include translations and editors in about dialog --- diff --git a/pv/application.cpp b/pv/application.cpp index 6f666c5c..8252f27f 100644 --- a/pv/application.cpp +++ b/pv/application.cpp @@ -65,7 +65,7 @@ Application::Application(int &argc, char* argv[]) : setOrganizationDomain("sigrok.org"); } -QStringList Application::get_languages() +const QStringList Application::get_languages() const { QStringList files = QDir(":/l10n/").entryList(QStringList("*.qm"), QDir::Files); @@ -81,6 +81,14 @@ QStringList Application::get_languages() return result; } +const QString Application::get_language_editors(const QString& language) const +{ + if (language == "de") return "Sören Apel, Uwe Hermann"; + if (language == "es_mx") return "Carlos Diaz"; + + return QString(); +} + void Application::switch_language(const QString& language) { removeTranslator(&app_translator_); diff --git a/pv/application.hpp b/pv/application.hpp index 61fe46e2..75ddbc06 100644 --- a/pv/application.hpp +++ b/pv/application.hpp @@ -41,8 +41,10 @@ class Application : public QApplication, public pv::GlobalSettingsInterface public: Application(int &argc, char* argv[]); - QStringList get_languages(); + const QStringList get_languages() const; + const QString get_language_editors(const QString& language) const; void switch_language(const QString& language); + void on_setting_changed(const QString &key, const QVariant &value); void collect_version_info(shared_ptr context); diff --git a/pv/dialogs/settings.cpp b/pv/dialogs/settings.cpp index 9f458c99..ccf6c519 100644 --- a/pv/dialogs/settings.cpp +++ b/pv/dialogs/settings.cpp @@ -222,8 +222,8 @@ QWidget *Settings::get_general_settings_form(QWidget *parent) const QString current_language = settings.value(GlobalSettings::Key_General_Language).toString(); for (const QString& language : a->get_languages()) { - QLocale locale = QLocale(language); - QString desc = locale.languageToString(locale.language()); + const QLocale locale = QLocale(language); + const QString desc = locale.languageToString(locale.language()); language_cb->addItem(desc, language); if (language == current_language) { @@ -499,6 +499,21 @@ QWidget *Settings::get_about_page(QWidget *parent) const .arg(entry.first, entry.second)); #endif + s.append(""); + s.append("" + + tr("Available Translations:") + ""); + for (const QString& language : a->get_languages()) { + if (language == "en") + continue; + + const QLocale locale = QLocale(language); + const QString desc = locale.languageToString(locale.language()); + const QString editors = a->get_language_editors(language); + + s.append(QString("%1(%2)") + .arg(desc, editors)); + } + s.append(""); QTextDocument *supported_doc = new QTextDocument();