Skip to content

Commit

Permalink
add russian translation
Browse files Browse the repository at this point in the history
  • Loading branch information
ddanilov committed Nov 11, 2023
1 parent bea9322 commit 1192c24
Show file tree
Hide file tree
Showing 6 changed files with 262 additions and 12 deletions.
13 changes: 11 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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}")

Expand Down
25 changes: 21 additions & 4 deletions src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,44 @@

#include <QApplication>
#include <QCommandLineParser>
#include <QLibraryInfo>
#include <QLocale>
#include <QTranslator>

int main(int argc, char* argv[])
{
QApplication a(argc, argv);
QApplication::setApplicationName(APP_TITLE);
QApplication::setApplicationVersion(APP_VERSION);

QList<QTranslator*> 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);

Expand Down
10 changes: 5 additions & 5 deletions src/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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)
Expand Down Expand Up @@ -373,7 +373,7 @@ void MainWindow::loadTracksFromJson(QFile& file)
void MainWindow::showAbout()
{
QString info;
info.append("<h3>" + tr(APP_TITLE) + "</h3>" + "\n");
info.append(QString("<h3>%1</h3>\n").arg(APP_TITLE));
info.append("<h4>" + tr("Version: %1").arg(APP_VERSION) + "</h4>" + "\n");

info.append(tr("open-source system-tray resident desktop application for playing soundscapes") + "<br>" + "\n");
Expand All @@ -387,5 +387,5 @@ void MainWindow::showAbout()
info.append(tr("Qt Version: %1").arg(qVersion()) + "\n");
info.append("<br>");

QMessageBox::about(this, tr("About") + " " + tr(APP_TITLE), info);
QMessageBox::about(this, tr("About"), info);
}
4 changes: 3 additions & 1 deletion src/PositionLabel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down
1 change: 1 addition & 0 deletions src/translations/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.ts eol=lf
221 changes: 221 additions & 0 deletions src/translations/soundscape_ru.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,221 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="ru_RU">
<context>
<name>Help</name>
<message>
<location filename="../Main.cpp" line="36"/>
<source>Load track list from file.</source>
<translation>Загрузить дорожки из файла.</translation>
</message>
<message>
<location filename="../Main.cpp" line="37"/>
<source>path to file</source>
<translation>путь к файлу</translation>
</message>
<message>
<location filename="../Main.cpp" line="40"/>
<source>Minimize window to tray.</source>
<translation>Запустить свёрнутым в область уведомления (системный лоток).</translation>
</message>
<message>
<location filename="../Main.cpp" line="44"/>
<source>Enable tray icon.</source>
<translation>Включить область уведомления (системный лоток).</translation>
</message>
<message>
<location filename="../Main.cpp" line="46"/>
<source>Disable tray icon.</source>
<translation>Выключить область уведомления (системный лоток).</translation>
</message>
</context>
<context>
<name>MainWindow</name>
<message>
<location filename="../MainWindow.cpp" line="45"/>
<source>Use mouse right-click
to access application menu</source>
<translation>Используйте правую кнопку мыши
для доступа к меню</translation>
</message>
<message>
<location filename="../MainWindow.cpp" line="51"/>
<location filename="../MainWindow.cpp" line="52"/>
<location filename="../MainWindow.cpp" line="110"/>
<location filename="../MainWindow.cpp" line="390"/>
<source>About</source>
<translation>О программе</translation>
</message>
<message>
<location filename="../MainWindow.cpp" line="77"/>
<source>Pause playing tracks</source>
<translation>Приостановить возпроизведение</translation>
</message>
<message>
<location filename="../MainWindow.cpp" line="80"/>
<source>Resume paused tracks</source>
<translation>Возобновить возпроизведение</translation>
</message>
<message>
<location filename="../MainWindow.cpp" line="86"/>
<source>Add track</source>
<translation>Добавить дорожку</translation>
</message>
<message>
<location filename="../MainWindow.cpp" line="89"/>
<source>Save track list</source>
<translation>Сохранить список дорожек</translation>
</message>
<message>
<location filename="../MainWindow.cpp" line="92"/>
<source>Load track list</source>
<translation>Загрузить список дорожек</translation>
</message>
<message>
<location filename="../MainWindow.cpp" line="95"/>
<source>Examples</source>
<translation>Примеры</translation>
</message>
<message>
<location filename="../MainWindow.cpp" line="98"/>
<source>Rain and Thunder</source>
<translation>Дождь с громом</translation>
</message>
<message>
<location filename="../MainWindow.cpp" line="101"/>
<source>River</source>
<translation>У реки</translation>
</message>
<message>
<location filename="../MainWindow.cpp" line="114"/>
<source>Quit</source>
<translation>Выход</translation>
</message>
<message>
<location filename="../MainWindow.cpp" line="269"/>
<source>Show window</source>
<translation>Показать окно</translation>
</message>
<message>
<location filename="../MainWindow.cpp" line="322"/>
<source>Save Tracks</source>
<translation>Сохранение дорожек</translation>
</message>
<message>
<location filename="../MainWindow.cpp" line="323"/>
<location filename="../MainWindow.cpp" line="346"/>
<source>couldn&apos;t open file: %1</source>
<translation>невозможно открыть файл %1</translation>
</message>
<message>
<location filename="../MainWindow.cpp" line="345"/>
<source>Load Tracks</source>
<translation>Загрузка дорожек</translation>
</message>
<message>
<location filename="../MainWindow.cpp" line="377"/>
<source>Version: %1</source>
<translation>Версия: %1</translation>
</message>
<message>
<location filename="../MainWindow.cpp" line="379"/>
<source>open-source system-tray resident desktop application for playing soundscapes</source>
<translation>приложение для воспроизведения звуковых ландшафтов</translation>
</message>
<message>
<location filename="../MainWindow.cpp" line="382"/>
<source>Website: &lt;a href=&quot;%1&quot;&gt;%1&lt;/a&gt;</source>
<translation>Веб-сайт: &lt;a href=&quot;%1&quot;&gt;%1&lt;/a&gt;</translation>
</message>
<message>
<location filename="../MainWindow.cpp" line="383"/>
<source>Copyright: © 2022-2023 Denis Danilov</source>
<translation>Копирайт: © 2022-2023 Denis Danilov</translation>
</message>
<message>
<location filename="../MainWindow.cpp" line="384"/>
<source>License: GNU General Public License (GPL) version 3</source>
<translation>Лицензия: GNU General Public License (GPL) version 3</translation>
</message>
<message>
<location filename="../MainWindow.cpp" line="387"/>
<source>Qt Version: %1</source>
<translation>Версия Qt: %1</translation>
</message>
</context>
<context>
<name>PositionLabel</name>
<message>
<location filename="../PositionLabel.h" line="18"/>
<source>%1 s</source>
<translation>%1 сек</translation>
</message>
</context>
<context>
<name>TrackControls</name>
<message>
<location filename="../TrackControls.cpp" line="173"/>
<source>Edit Settings</source>
<translation>Параметры</translation>
</message>
<message>
<location filename="../TrackControls.cpp" line="176"/>
<source>Move Up</source>
<translation>Переместить вверх</translation>
</message>
<message>
<location filename="../TrackControls.cpp" line="179"/>
<source>Move Down</source>
<translation>Переместить вниз</translation>
</message>
<message>
<location filename="../TrackControls.cpp" line="182"/>
<source>Remove</source>
<translation>Удалить</translation>
</message>
</context>
<context>
<name>TrackSettings</name>
<message>
<location filename="../TrackSettings.cpp" line="91"/>
<source>track duration</source>
<translation>продолжительность дорожки</translation>
</message>
<message>
<location filename="../TrackSettings.cpp" line="112"/>
<source>fade-in</source>
<translation>нарастание</translation>
</message>
<message>
<location filename="../TrackSettings.cpp" line="119"/>
<source>fade-out</source>
<translation>затухание</translation>
</message>
<message>
<location filename="../TrackSettings.cpp" line="127"/>
<source>player A</source>
<translation>проигрыватель А</translation>
</message>
<message>
<location filename="../TrackSettings.cpp" line="134"/>
<source>player B</source>
<translation>проигрыватель Б</translation>
</message>
<message>
<location filename="../TrackSettings.cpp" line="175"/>
<source>gap</source>
<translation>промежуток</translation>
</message>
<message>
<location filename="../TrackSettings.cpp" line="177"/>
<location filename="../TrackSettings.cpp" line="183"/>
<source>s</source>
<translation>сек</translation>
</message>
<message>
<location filename="../TrackSettings.cpp" line="181"/>
<source>random up to</source>
<translation>случайный до</translation>
</message>
</context>
</TS>

0 comments on commit 1192c24

Please sign in to comment.