From 1192c24541a3bbbc17b9956141548dadc900bacd Mon Sep 17 00:00:00 2001 From: Denis Danilov Date: Sat, 11 Nov 2023 16:58:38 +0100 Subject: [PATCH] add russian translation --- src/CMakeLists.txt | 13 +- src/Main.cpp | 25 +++- src/MainWindow.cpp | 10 +- src/PositionLabel.h | 4 +- src/translations/.gitattributes | 1 + src/translations/soundscape_ru.ts | 221 ++++++++++++++++++++++++++++++ 6 files changed, 262 insertions(+), 12 deletions(-) create mode 100644 src/translations/.gitattributes create mode 100644 src/translations/soundscape_ru.ts diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ad08007..a49ce0a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,7 +1,11 @@ # SPDX-FileCopyrightText: 2022-2023 Denis Danilov # SPDX-License-Identifier: GPL-3.0-only -find_package(Qt6 6.2 COMPONENTS Multimedia Widgets REQUIRED) +find_package(Qt6 6.2 COMPONENTS + LinguistTools + Multimedia + Widgets + REQUIRED) message(STATUS "Using Qt ${Qt6_VERSION} from ${Qt6_DIR}") if(Qt6_VERSION VERSION_GREATER_EQUAL 6.3) @@ -58,7 +62,12 @@ qt_add_library(${APP_LIB} STATIC ${HEADERS} ${SOURCES} ) -target_link_libraries(${APP_LIB} Qt::Multimedia Qt::Widgets) +target_link_libraries(${APP_LIB} PUBLIC Qt::Multimedia Qt::Widgets) + +qt_add_translations(${APP_LIB} TS_FILES + translations/soundscape_ru.ts +) +add_dependencies(${APP_LIB} ${APP_LIB}_lupdate) message(STATUS "system name: ${CMAKE_SYSTEM_NAME}") diff --git a/src/Main.cpp b/src/Main.cpp index 12e21c1..31189a2 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -6,6 +6,9 @@ #include #include +#include +#include +#include int main(int argc, char* argv[]) { @@ -13,20 +16,34 @@ int main(int argc, char* argv[]) QApplication::setApplicationName(APP_TITLE); QApplication::setApplicationVersion(APP_VERSION); + QList translators; + auto loadTranslation = [&translators, &a](const auto& name, const auto& path) { + auto* translator = translators.emplace_back(new QTranslator(&a)); + if (translator->load(QLocale::system(), name, "_", path)) + { + QApplication::installTranslator(translator); + } + }; + loadTranslation("soundscape", ":/i18n/"); + loadTranslation("qtbase", QLibraryInfo::path(QLibraryInfo::TranslationsPath)); + loadTranslation("qtmultimedia", QLibraryInfo::path(QLibraryInfo::TranslationsPath)); + QCommandLineParser parser; parser.addHelpOption(); parser.addVersionOption(); - const QCommandLineOption load_option("load", "Load track list from file.", "path to file"); + const QCommandLineOption load_option("load", + QCoreApplication::translate("Help", "Load track list from file."), + QCoreApplication::translate("Help", "path to file")); parser.addOption(load_option); - const QCommandLineOption minimize_option("minimize", "Minimize window to tray."); + const QCommandLineOption minimize_option("minimize", QCoreApplication::translate("Help", "Minimize window to tray.")); parser.addOption(minimize_option); #if defined(Q_OS_MACOS) - const QCommandLineOption tray_option("enable-tray", "Enable tray icon."); + const QCommandLineOption tray_option("enable-tray", QCoreApplication::translate("Help", "Enable tray icon.")); #else - const QCommandLineOption tray_option("disable-tray", "Disable tray icon."); + const QCommandLineOption tray_option("disable-tray", QCoreApplication::translate("Help", "Disable tray icon.")); #endif parser.addOption(tray_option); diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index f086ac6..f889fa7 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -30,7 +30,7 @@ MainWindow::MainWindow(const bool disable_tray, QWidget* parent) : { setupTrayIcon(); - setWindowTitle(tr(APP_TITLE)); + setWindowTitle(APP_TITLE); addPauseResumeItemsToMenu(m_mouse_menu); addTrackItemsToMenu(m_mouse_menu); @@ -42,8 +42,8 @@ MainWindow::MainWindow(const bool disable_tray, QWidget* parent) : m_box_layout->setAlignment(Qt::AlignTop); m_menu_info->setTextFormat(Qt::PlainText); - m_menu_info->setText("Use mouse right-click\n" - "to access application menu"); + m_menu_info->setText(tr("Use mouse right-click\n" + "to access application menu")); m_box_layout->addWidget(m_menu_info, 0, Qt::AlignCenter); #if defined(Q_OS_MACOS) @@ -373,7 +373,7 @@ void MainWindow::loadTracksFromJson(QFile& file) void MainWindow::showAbout() { QString info; - info.append("

" + tr(APP_TITLE) + "

" + "\n"); + info.append(QString("

%1

\n").arg(APP_TITLE)); info.append("

" + tr("Version: %1").arg(APP_VERSION) + "

" + "\n"); info.append(tr("open-source system-tray resident desktop application for playing soundscapes") + "
" + "\n"); @@ -387,5 +387,5 @@ void MainWindow::showAbout() info.append(tr("Qt Version: %1").arg(qVersion()) + "\n"); info.append("
"); - QMessageBox::about(this, tr("About") + " " + tr(APP_TITLE), info); + QMessageBox::about(this, tr("About"), info); } diff --git a/src/PositionLabel.h b/src/PositionLabel.h index b26630b..dfa174d 100644 --- a/src/PositionLabel.h +++ b/src/PositionLabel.h @@ -7,13 +7,15 @@ class PositionLabel : public QLabel { + Q_OBJECT + public: explicit PositionLabel(QWidget* parent = nullptr); void setMax(double value); void setValue(double value); private: - const QString m_text_template{"%1 s"}; + const QString m_text_template{tr("%1 s")}; int m_field_width{3}; int m_precision{1}; diff --git a/src/translations/.gitattributes b/src/translations/.gitattributes new file mode 100644 index 0000000..02eeb60 --- /dev/null +++ b/src/translations/.gitattributes @@ -0,0 +1 @@ +*.ts eol=lf diff --git a/src/translations/soundscape_ru.ts b/src/translations/soundscape_ru.ts new file mode 100644 index 0000000..5582181 --- /dev/null +++ b/src/translations/soundscape_ru.ts @@ -0,0 +1,221 @@ + + + + + Help + + + Load track list from file. + Загрузить дорожки из файла. + + + + path to file + путь к файлу + + + + Minimize window to tray. + Запустить свёрнутым в область уведомления (системный лоток). + + + + Enable tray icon. + Включить область уведомления (системный лоток). + + + + Disable tray icon. + Выключить область уведомления (системный лоток). + + + + MainWindow + + + Use mouse right-click +to access application menu + Используйте правую кнопку мыши +для доступа к меню + + + + + + + About + О программе + + + + Pause playing tracks + Приостановить возпроизведение + + + + Resume paused tracks + Возобновить возпроизведение + + + + Add track + Добавить дорожку + + + + Save track list + Сохранить список дорожек + + + + Load track list + Загрузить список дорожек + + + + Examples + Примеры + + + + Rain and Thunder + Дождь с громом + + + + River + У реки + + + + Quit + Выход + + + + Show window + Показать окно + + + + Save Tracks + Сохранение дорожек + + + + + couldn't open file: %1 + невозможно открыть файл %1 + + + + Load Tracks + Загрузка дорожек + + + + Version: %1 + Версия: %1 + + + + open-source system-tray resident desktop application for playing soundscapes + приложение для воспроизведения звуковых ландшафтов + + + + Website: <a href="%1">%1</a> + Веб-сайт: <a href="%1">%1</a> + + + + Copyright: © 2022-2023 Denis Danilov + Копирайт: © 2022-2023 Denis Danilov + + + + License: GNU General Public License (GPL) version 3 + Лицензия: GNU General Public License (GPL) version 3 + + + + Qt Version: %1 + Версия Qt: %1 + + + + PositionLabel + + + %1 s + %1 сек + + + + TrackControls + + + Edit Settings + Параметры + + + + Move Up + Переместить вверх + + + + Move Down + Переместить вниз + + + + Remove + Удалить + + + + TrackSettings + + + track duration + продолжительность дорожки + + + + fade-in + нарастание + + + + fade-out + затухание + + + + player A + проигрыватель А + + + + player B + проигрыватель Б + + + + gap + промежуток + + + + + s + сек + + + + random up to + случайный до + + +