From ccd9ec6ee94aa9a6aa16240d49234564e9a3a79d Mon Sep 17 00:00:00 2001 From: Nikolay Tischenko Date: Sun, 31 Oct 2010 17:03:55 +0600 Subject: [PATCH] Implement translations, added russian translation --- .gitignore | 3 + resources/.gitignore | 1 + resources/someplayer_ru.ts | 785 ++++++++++++++++++++++++++++++++++++++++++++ someplayer.pro | 2 + src/config.cpp | 2 + src/libraryform.cpp | 18 +- src/main.cpp | 8 + src/mainwindow.cpp | 4 + src/settingsdialog.cpp | 19 ++ src/settingsdialog.h | 2 + src/ui/settingsdialog.ui | 38 ++- 11 files changed, 871 insertions(+), 11 deletions(-) create mode 100644 resources/.gitignore create mode 100644 resources/someplayer_ru.ts diff --git a/.gitignore b/.gitignore index 15cf7a4..c6fce46 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ someplayer.pro.user +someplayer +*.o +*~ diff --git a/resources/.gitignore b/resources/.gitignore new file mode 100644 index 0000000..8df47d5 --- /dev/null +++ b/resources/.gitignore @@ -0,0 +1 @@ +*.qm diff --git a/resources/someplayer_ru.ts b/resources/someplayer_ru.ts new file mode 100644 index 0000000..a4d6e7f --- /dev/null +++ b/resources/someplayer_ru.ts @@ -0,0 +1,785 @@ + + + + + DirectoryView + + + Directories + Каталоги + + + + EditTagsDialog + + + Edit tags + Редактировать теги + + + + Artist: + Исполнитель: + + + + Album: + Альбом: + + + + Title: + Название: + + + + EqualizerDialog + + + Equalizer + Эквалайзер + + + + +12dB + +12dB + + + + -12dB + -12dB + + + + Enable + Включен + + + + Save + Сохранить + + + + LibraryForm + + + Library + Библиотека + + + + Artists + Исполнители + + + + Dynamic playlists + Динамические плейлисты + + + + + Albums by "%1" + Альбомы "%1" + + + + Tracks from "%1" by "%2" + Треки из "%1" от "%2" + + + + All tracks by "%1" + Все треки "%1" + + + + Tracks in playlist "%1" + Треки плейлиста "%1" + + + + Playlists + Плейлисты + + + + Search in library + Поиск по библиотеке + + + + MainWindow + + + someplayer + someplayer + + + + Main + Главное + + + + Library + Библиотека + + + + Tools + Инструменты + + + + Player + Плеер + + + + About + О программе + + + + Settings + Настройки + + + + Manage library + Управление библиотекой + + + + Equalizer + Эквалайзер + + + + Set timer + Таймер выключения + + + + Save playlist + Сохранить плейлист + + + + Ctrl+S + Ctrl+S + + + + ManageLibraryForm + + + Manage library + Управление библиотекой + + + + Added directories: + Добавленные каталоги: + + + + 0 artitst + + + + + 0 albums + + + + + 0 tracks + + + + + PlayerForm + + + SomePlayer + SomePlayer + + + + Music off: + Отключение через: + + + + 00:00:00 + 00:00:00 + + + + 0/0 + 0/0 + + + + <h3>Title</h3> + <h3>Название</h3> + + + + + 00:00 + 00:00 + + + + <b>Artist</b><br/>album + <b>Исполнитель</b><br/>альбом + + + + PlaylistDialog + + + Dialog + + + + + QObject + + + All tracks + Все треки + + + + SavePlaylistDialog + + + Save playlist + Сохранить плейлист + + + + Existed playlists: + Плейлисты: + + + + New: + Новый: + + + + SettingsDialog + + + Settings + Настройки + + + + Icons theme: + Тема иконок: + + + + White + Белые + + + + Black + Чёрные + + + + Use gradient in portrait mode: + Использовать градиент: + + + + + Yes + Да + + + + + No + Нет + + + + Sort album: + Сортировать альбомы: + + + + Alphabetical + По алфавиту + + + + By date + По году + + + + Orientation: + Ориентация: + + + + Landscape + Ландшафтный + + + + Portrait + Портретный + + + + Auto + Авто + + + + Show track lenght in library view: + Показывать длину трека в библиотеке: + + + + Language: + Язык: + + + + English + Английский + + + + Russian + Русский + + + + TimerDialog + + + Set timer + Установить таймер + + + + Hours + Часы + + + + + + 00 + + + + + + + 01 + + + + + + + 02 + + + + + + + 03 + + + + + + + 04 + + + + + + + 05 + + + + + + + 06 + + + + + + + 07 + + + + + + + 08 + + + + + + + 09 + + + + + + + 10 + + + + + + + 11 + + + + + + + 12 + + + + + + : + + + + + Minutes + Минуты + + + + + 13 + + + + + + 14 + + + + + + 15 + + + + + + 16 + + + + + + 17 + + + + + + 18 + + + + + + 19 + + + + + + 20 + + + + + + 21 + + + + + + 22 + + + + + + 23 + + + + + + 24 + + + + + + 25 + + + + + + 26 + + + + + + 27 + + + + + + 28 + + + + + + 29 + + + + + + 30 + + + + + + 31 + + + + + + 32 + + + + + + 33 + + + + + + 34 + + + + + + 35 + + + + + + 36 + + + + + + 37 + + + + + + 38 + + + + + + 40 + + + + + + 41 + + + + + + 42 + + + + + + 43 + + + + + + 44 + + + + + + 45 + + + + + + 46 + + + + + + 47 + + + + + + 48 + + + + + + 49 + + + + + + 50 + + + + + + 51 + + + + + + 52 + + + + + + 53 + + + + + + 54 + + + + + + 55 + + + + + + 56 + + + + + + 57 + + + + + + 58 + + + + + + 59 + + + + + Seconds + Секунды + + + + 39 + + + + + Disable + Отключить + + + + ToolsWidget + + + Form + + + + diff --git a/someplayer.pro b/someplayer.pro index 2a1ae52..d449c94 100644 --- a/someplayer.pro +++ b/someplayer.pro @@ -270,3 +270,5 @@ OTHER_FILES += \ src/taglib/toolkit/tlist.tcc \ AUTHORS.TagLib \ COPYING.LGPL + +TRANSLATIONS = resources/someplayer_ru.ts diff --git a/src/config.cpp b/src/config.cpp index 49ccfa4..ea1d02e 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -32,6 +32,8 @@ Config::Config() _settings->setValue("ui/albumsorting", "date"); if (_settings->value("ui/gradient").toString() == "") _settings->setValue("ui/gradient", "yes"); + if (_settings->value("ui/language").toString() == "") + _settings->setValue("ui/language", "en"); } Config::~Config() { diff --git a/src/libraryform.cpp b/src/libraryform.cpp index f02b440..7ccfb78 100644 --- a/src/libraryform.cpp +++ b/src/libraryform.cpp @@ -170,7 +170,7 @@ void LibraryForm::_view_button() { _state = STATE_ARTIST; ui->backButton->setEnabled(false); ui->backButton->setIcon(QIcon()); - ui->listLabel->setText("Artists"); + ui->listLabel->setText(tr("Artists")); ui->useButton->setEnabled(false); ui->useButton->setIcon(QIcon()); ui->addButton->setEnabled(false); @@ -197,7 +197,7 @@ void LibraryForm::_dynamic_button() { _model->setItem(3, 0, new QStandardItem(QIcon(":/icons/"+_icons_theme+"/deselect_all.png"), "")); _model->setItem(3, 1, new QStandardItem("Recently added")); ui->listView->setColumnWidth(0, 70); - ui->listLabel->setText("Dynamic playlists"); + ui->listLabel->setText(tr("Dynamic playlists")); _state = STATE_DYNAMIC; ui->addButton->setEnabled(false); ui->addButton->setIcon(QIcon()); @@ -221,7 +221,7 @@ void LibraryForm::_process_list_click(QModelIndex index) { _state = STATE_ALBUM; ui->backButton->setEnabled(true); ui->backButton->setIcon(QIcon(":/icons/"+_icons_theme+"/back.png")); - ui->listLabel->setText(QString("Albums by \"%1\"").arg(_current_artist)); + ui->listLabel->setText(QString(tr("Albums by \"%1\"")).arg(_current_artist)); break; case STATE_ALBUM: if (regexp.indexIn(data) != -1) { @@ -233,7 +233,7 @@ void LibraryForm::_process_list_click(QModelIndex index) { _state = STATE_TRACK; ui->backButton->setEnabled(true); ui->backButton->setIcon(QIcon(":/icons/"+_icons_theme+"/back.png")); - ui->listLabel->setText(QString("Tracks from \"%1\" by \"%2\"").arg(_current_album).arg(_current_artist)); + ui->listLabel->setText(QString(tr("Tracks from \"%1\" by \"%2\"")).arg(_current_album).arg(_current_artist)); } else { if (index.row() == 0) { // all tracks _current_tracks = _lib->getAllTracksForArtist(_current_artist); @@ -243,7 +243,7 @@ void LibraryForm::_process_list_click(QModelIndex index) { _state = STATE_TRACK; ui->backButton->setEnabled(true); ui->backButton->setIcon(QIcon(":/icons/"+_icons_theme+"/back.png")); - ui->listLabel->setText(QString("All tracks by \"%1\"").arg(_current_artist)); + ui->listLabel->setText(QString(tr("All tracks by \"%1\"")).arg(_current_artist)); } } break; @@ -260,7 +260,7 @@ void LibraryForm::_process_list_click(QModelIndex index) { ui->backButton->setIcon(QIcon(":/icons/"+_icons_theme+"/back.png")); ui->useButton->setEnabled(true); ui->useButton->setIcon(QIcon(":/icons/"+_icons_theme+"/use.png")); - ui->listLabel->setText(QString("Tracks in playlist \"%1\"").arg(data)); + ui->listLabel->setText(QString(tr("Tracks in playlist \"%1\"")).arg(data)); } break; case STATE_DYNAMIC: @@ -396,7 +396,7 @@ void LibraryForm::_back_button() { ui->listView->setColumnWidth(0, 70); ui->listView->scrollToTop(); _state = STATE_ALBUM; - ui->listLabel->setText(QString("Albums by \"%1\"").arg(_current_artist)); + ui->listLabel->setText(QString(tr("Albums by \"%1\"")).arg(_current_artist)); break; case STATE_PLAYLIST_TRACK: if (_is_dynamic) { @@ -418,7 +418,7 @@ void LibraryForm::_playlists_button() { _state = STATE_PLAYLIST; ui->backButton->setEnabled(false); ui->backButton->setIcon(QIcon()); - ui->listLabel->setText("Playlists"); + ui->listLabel->setText(tr("Playlists")); ui->useButton->setEnabled(false); ui->useButton->setIcon(QIcon()); ui->addButton->setEnabled(false); @@ -775,7 +775,7 @@ void LibraryForm::_search_button(bool state) { _tools_widget->setFocus(); _tools_widget->reset(); if (state) { - ui->listLabel->setText("Search in library"); + ui->listLabel->setText(tr("Search in library")); ui->deleteButton->setIcon(QIcon()); ui->deleteButton->setEnabled(false); ui->useButton->setIcon(QIcon()); diff --git a/src/main.cpp b/src/main.cpp index 2d46863..ee0a444 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -18,11 +18,19 @@ */ #include +#include #include "mainwindow.h" +#include "config.h" + +using namespace SomePlayer::Storage; int main(int argc, char *argv[]) { QApplication a(argc, argv); + QTranslator *translator = new QTranslator(0); + Config config; + translator->load(QString("/opt/someplayer/someplayer_%1").arg(config.getValue("ui/language").toString())); + a.installTranslator(translator); a.setApplicationName("ru.somebody.someplayer"); MainWindow w; w.setAttribute(Qt::WA_Maemo5StackedWindow); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index a3acf75..f71f9dc 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include "player/player.h" @@ -276,6 +277,9 @@ void MainWindow::settings() { _library_form->checkGradient(); _directory_form->updateIcons(); _directory_form->updateGradient(); + QTranslator *translator = new QTranslator(this); + translator->load(QString("/opt/someplayer/someplayer_%1").arg(config.getValue("ui/language").toString())); + QApplication::installTranslator(translator); } void MainWindow::_orientation_changed() { diff --git a/src/settingsdialog.cpp b/src/settingsdialog.cpp index 10e5831..0c54f85 100644 --- a/src/settingsdialog.cpp +++ b/src/settingsdialog.cpp @@ -34,11 +34,13 @@ SettingsDialog::SettingsDialog(QWidget *parent) : QString orientation = config.getValue("ui/orientation").toString(); QString icons_theme = config.getValue("ui/iconstheme").toString(); QString gradient = config.getValue("ui/gradient").toString(); + QString language = config.getValue("ui/language").toString(); ui->albumsSortDButton->setChecked(true); // defaule sorting ui->showTrackLenghtYButton->setChecked(true); // show by default ui->orientationLButton->setChecked(true); ui->iconsWButton->setChecked(true); ui->gradientYButton->setChecked(true); + ui->engLangButton->setChecked(true); if (albumSorting == "alphabet") { ui->albumsSortAButton->setChecked(true); } @@ -56,6 +58,9 @@ SettingsDialog::SettingsDialog(QWidget *parent) : if (gradient == "no") { ui->gradientNButton->setChecked(true); } + if (language == "ru") { + ui->ruLangButton->setChecked(true); + } connect (ui->albumsSortAButton, SIGNAL(toggled(bool)), this, SLOT(_set_album_sorting_alphabet(bool))); connect (ui->albumsSortDButton, SIGNAL(toggled(bool)), this, SLOT(_set_album_sorting_date(bool))); connect (ui->showTrackLenghtNButton, SIGNAL(toggled(bool)), this, SLOT(_set_track_lenght_show_no(bool))); @@ -67,6 +72,8 @@ SettingsDialog::SettingsDialog(QWidget *parent) : connect (ui->iconsWButton, SIGNAL(toggled(bool)), this, SLOT(_set_icons_white(bool))); connect (ui->gradientNButton, SIGNAL(toggled(bool)), this, SLOT(_set_gradient_no(bool))); connect (ui->gradientYButton, SIGNAL(toggled(bool)), this, SLOT(_set_gradient_yes(bool))); + connect (ui->engLangButton, SIGNAL(toggled(bool)), this, SLOT(_set_lang_en(bool))); + connect (ui->ruLangButton, SIGNAL(toggled(bool)), this, SLOT(_set_lang_ru(bool))); } SettingsDialog::~SettingsDialog() @@ -139,3 +146,15 @@ void SettingsDialog::_set_gradient_yes(bool checked) { Config config; config.setValue("ui/gradient", "yes"); } + +void SettingsDialog::_set_lang_en(bool checked) { + if (!checked) return; + Config config; + config.setValue("ui/language", "en"); +} + +void SettingsDialog::_set_lang_ru(bool checked) { + if (!checked) return; + Config config; + config.setValue("ui/language", "ru"); +} diff --git a/src/settingsdialog.h b/src/settingsdialog.h index 02a9bf9..037e6cb 100644 --- a/src/settingsdialog.h +++ b/src/settingsdialog.h @@ -50,6 +50,8 @@ private slots: void _set_icons_black(bool); void _set_gradient_yes(bool); void _set_gradient_no(bool); + void _set_lang_en(bool); + void _set_lang_ru(bool); }; #endif // SETTINGSDIALOG_H diff --git a/src/ui/settingsdialog.ui b/src/ui/settingsdialog.ui index fe45815..a6295c2 100644 --- a/src/ui/settingsdialog.ui +++ b/src/ui/settingsdialog.ui @@ -25,9 +25,9 @@ 0 - 0 + -82 760 - 367 + 438 @@ -211,6 +211,40 @@ + + + + + + + + + + Language: + + + + + + + + + English + + + + + + + Russian + + + + + + + + -- 1.7.9.5