diff --git a/doc/translate.html b/doc/translate.html
index 7124b892..93d034ed 100644
--- a/doc/translate.html
+++ b/doc/translate.html
@@ -14,7 +14,7 @@
Editing the language file:
LameXP v4.xx translations are created as TS (translation) files, which can be edited using the Qt Linguist application. For new translations an empty TS file ("Blank.ts") is provided in the LameXP Git repository. When you open the empty TS file for the first time, Linguist will ask for some basic settings. Here you must keep the "Source language" options at "English" and "Any Country". Change the "Target language" options to whatever language (region) you are going to translate too. Once you have edited all (or some) text strings, you can save your work to a TS file again. It is recommended to save your work to "LameXP_XX.ts", where XX should be replaced with the suitable upper-case ISO 639-1 country code (for example the German translation is saved as "LameXP_DE.ts"). You can re-open your TS file at any time in order to continue with your work. In case you want to improve an existing LameXP translation, simply download the corresponding TS file from the LameXP Git repository and edit it using the Qt Linguist tool.
-The latest translation (TS) files can always be found in the LameXP Git repository at:https://github.com/lordmulder/LameXP/tree/master/etc/Translation
+The latest translation (TS) files can always be found in the LameXP Git repository at:https://github.com/lordmulder/LameXP/tree/master/etc/Translation (After you have chosen a file from the directory tree, you can download the file by right-clicking on "raw" an choosing "Save Link Target As...")
Important: Before you start translating, always make sure your download the latest "Blank.ts" file from the LameXP Git repository. If you want to edit an existing translation, including translations you have created yourself, make sure your download the latest TS file from the LameXP Git repository. Never ever do any translations based on an old working copy (TS file) from your local system! The translation files in the repository will be updated, as the development proceeds.
Language file editing rules:
diff --git a/etc/Translation/Blank.ts b/etc/Translation/Blank.ts
index 08f81243..0a689b58 100644
--- a/etc/Translation/Blank.ts
+++ b/etc/Translation/Blank.ts
@@ -462,6 +462,10 @@
Show DropBox
+
+ From File...
+
+
Adding file(s), please wait...
@@ -674,6 +678,14 @@
Add folder
+
+ Load Translation
+
+
+
+ Translation Files
+
+
New Folder
diff --git a/etc/Translation/LameXP_DE.ts b/etc/Translation/LameXP_DE.ts
index 0b83041b..39602a74 100644
--- a/etc/Translation/LameXP_DE.ts
+++ b/etc/Translation/LameXP_DE.ts
@@ -831,6 +831,18 @@
No
Nein
+
+ From File...
+ Von Datei...
+
+
+ Load Translation
+ Übersetzung Laden
+
+
+ Translation Files
+ Übersetzungsdateien
+
MetaInfo
diff --git a/gui/MainWindow.ui b/gui/MainWindow.ui
index 5362c750..a0d66b7f 100644
--- a/gui/MainWindow.ui
+++ b/gui/MainWindow.ui
@@ -1229,6 +1229,7 @@
:/icons/font.png :/icons/font.png
+
@@ -1476,6 +1477,15 @@
English
+
+
+
+ :/icons/folder_page.png :/icons/folder_page.png
+
+
+ From File...
+
+
@@ -1489,6 +1499,10 @@
+
+
+
+
diff --git a/res/localization/LameXP_DE.qm b/res/localization/LameXP_DE.qm
index e6425371..b05b4f26 100644
Binary files a/res/localization/LameXP_DE.qm and b/res/localization/LameXP_DE.qm differ
diff --git a/src/Config.h b/src/Config.h
index 2ed971e2..b3410b93 100644
--- a/src/Config.h
+++ b/src/Config.h
@@ -25,7 +25,7 @@
#define VER_LAMEXP_MAJOR 4
#define VER_LAMEXP_MINOR_HI 0
#define VER_LAMEXP_MINOR_LO 0
-#define VER_LAMEXP_BUILD 217
+#define VER_LAMEXP_BUILD 218
#define VER_LAMEXP_SUFFIX TechPreview
/*
diff --git a/src/Dialog_MainWindow.cpp b/src/Dialog_MainWindow.cpp
index 527aee6a..c5ee59cb 100644
--- a/src/Dialog_MainWindow.cpp
+++ b/src/Dialog_MainWindow.cpp
@@ -250,19 +250,21 @@ MainWindow::MainWindow(FileListModel *fileListModel, AudioFileModel *metaInfo, S
//Populate the language menu
m_languageActionGroup = new QActionGroup(this);
- connect(m_languageActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(languageActionActivated(QAction*)));
QStringList translations = lamexp_query_translations();
while(!translations.isEmpty())
{
- QString langId = translations.takeFirst();
+ QString langId = translations.takeLast();
QAction *currentLanguage = new QAction(this);
currentLanguage->setData(langId);
currentLanguage->setText(lamexp_translation_name(langId));
currentLanguage->setIcon(QIcon(QString(":/flags/%1.png").arg(langId)));
currentLanguage->setCheckable(true);
m_languageActionGroup->addAction(currentLanguage);
- menuLanguage->addAction(currentLanguage);
+ menuLanguage->insertAction(actionLoadTranslationFromFile, currentLanguage);
}
+ menuLanguage->insertSeparator(actionLoadTranslationFromFile);
+ connect(actionLoadTranslationFromFile, SIGNAL(triggered(bool)), this, SLOT(languageFromFileActionActivated(bool)));
+ connect(m_languageActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(languageActionActivated(QAction*)));
//Activate tools menu actions
actionDisableUpdateReminder->setChecked(!m_settings->autoUpdateEnabled());
@@ -1039,11 +1041,42 @@ void MainWindow::styleActionActivated(QAction *action)
*/
void MainWindow::languageActionActivated(QAction *action)
{
- QString langId = action->data().toString();
-
- if(lamexp_install_translator(langId))
+ if(action->data().type() == QVariant::String)
{
- m_settings->currentLanguage(langId);
+ QString langId = action->data().toString();
+
+ if(lamexp_install_translator(langId))
+ {
+ action->setChecked(true);
+ m_settings->currentLanguage(langId);
+ }
+ }
+}
+
+/*
+ * Load language from file action triggered
+ */
+void MainWindow::languageFromFileActionActivated(bool checked)
+{
+ QFileDialog dialog(this, tr("Load Translation"));
+ dialog.setFileMode(QFileDialog::ExistingFile);
+ dialog.setNameFilter(QString("%1 (*.qm)").arg(tr("Translation Files")));
+
+ if(dialog.exec())
+ {
+ QStringList selectedFiles = dialog.selectedFiles();
+ if(lamexp_install_translator_from_file(selectedFiles.first()))
+ {
+ QList actions = m_languageActionGroup->actions();
+ while(!actions.isEmpty())
+ {
+ actions.takeFirst()->setChecked(false);
+ }
+ }
+ else
+ {
+ languageActionActivated(m_languageActionGroup->actions().first());
+ }
}
}
diff --git a/src/Dialog_MainWindow.h b/src/Dialog_MainWindow.h
index 2a46ff18..b0d19d52 100644
--- a/src/Dialog_MainWindow.h
+++ b/src/Dialog_MainWindow.h
@@ -61,6 +61,7 @@ private slots:
void tabActionActivated(QAction *action);
void styleActionActivated(QAction *action);
void languageActionActivated(QAction *action);
+ void languageFromFileActionActivated(bool checked);
void outputFolderViewClicked(const QModelIndex &index);
void outputFolderViewMoved(const QModelIndex &index);
void makeFolderButtonClicked(void);
diff --git a/src/Global.cpp b/src/Global.cpp
index 2f2c2de5..5279fca0 100644
--- a/src/Global.cpp
+++ b/src/Global.cpp
@@ -917,24 +917,16 @@ bool lamexp_install_translator(const QString &langId)
{
bool success = false;
- if(!g_lamexp_currentTranslator)
- {
- g_lamexp_currentTranslator = new QTranslator();
- }
-
if(langId.isEmpty() || langId.toLower().compare(LAMEXP_DEFAULT_LANGID) == 0)
{
- QApplication::removeTranslator(g_lamexp_currentTranslator);
- success = true;
+ success = lamexp_install_translator_from_file(QString());
}
else
{
QString qmFile = g_lamexp_translation_files.value(langId.toLower(), QString());
if(!qmFile.isEmpty())
{
- QApplication::removeTranslator(g_lamexp_currentTranslator);
- success = g_lamexp_currentTranslator->load(QString(":/localization/%1").arg(qmFile));
- QApplication::installTranslator(g_lamexp_currentTranslator);
+ success = lamexp_install_translator_from_file(QString(":/localization/%1").arg(qmFile));
}
else
{
@@ -945,6 +937,38 @@ bool lamexp_install_translator(const QString &langId)
return success;
}
+/*
+ * Install a new translator from file
+ */
+bool lamexp_install_translator_from_file(const QString &qmFile)
+{
+ bool success = false;
+
+ if(!g_lamexp_currentTranslator)
+ {
+ g_lamexp_currentTranslator = new QTranslator();
+ }
+
+ if(!qmFile.isEmpty())
+ {
+ QString qmPath = QFileInfo(qmFile).canonicalFilePath();
+ QApplication::removeTranslator(g_lamexp_currentTranslator);
+ success = g_lamexp_currentTranslator->load(qmPath);
+ QApplication::installTranslator(g_lamexp_currentTranslator);
+ if(!success)
+ {
+ qWarning("Failed to load translation:\n\"%s\"", qmPath.toLatin1().constData());
+ }
+ }
+ else
+ {
+ QApplication::removeTranslator(g_lamexp_currentTranslator);
+ success = true;
+ }
+
+ return success;
+}
+
/*
* Locate known folder on local system
*/
diff --git a/src/Global.h b/src/Global.h
index 0379fbc6..7a3e052e 100644
--- a/src/Global.h
+++ b/src/Global.h
@@ -97,6 +97,7 @@ QStringList lamexp_query_translations(void);
bool lamexp_translation_register(const QString &langId, const QString &qmFile, const QString &langName, unsigned int &systemId);
QString lamexp_translation_name(const QString &language);
unsigned int lamexp_translation_sysid(const QString &langId);
+bool lamexp_install_translator_from_file(const QString &qmFile);
bool lamexp_install_translator(const QString &language);
static const char* LAMEXP_DEFAULT_LANGID = "en";