Added option to load translations from an "external" file, for easier translation testing.
This commit is contained in:
parent
8903bb4f03
commit
bb538580d6
@ -14,7 +14,7 @@
|
|||||||
<br>
|
<br>
|
||||||
<h3>Editing the language file:</h3>
|
<h3>Editing the language file:</h3>
|
||||||
<p>LameXP v4.xx translations are created as TS (translation) files, which can be edited using the <i>Qt Linguist</i> 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 <i>XX</i> should be replaced with the suitable upper-case <a href="http://www.loc.gov/standards/iso639-2/php/code_list.php" target="_blank">ISO 639-1</a> 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.</p>
|
<p>LameXP v4.xx translations are created as TS (translation) files, which can be edited using the <i>Qt Linguist</i> 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 <i>XX</i> should be replaced with the suitable upper-case <a href="http://www.loc.gov/standards/iso639-2/php/code_list.php" target="_blank">ISO 639-1</a> 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.</p>
|
||||||
<p>The latest translation (TS) files can always be found in the LameXP Git repository at:<br><a href="https://github.com/lordmulder/LameXP/tree/master/etc/Translation" target="_blank">https://github.com/lordmulder/LameXP/tree/master/etc/Translation</a></p>
|
<p>The latest translation (TS) files can always be found in the LameXP Git repository at:<br><a href="https://github.com/lordmulder/LameXP/tree/master/etc/Translation" target="_blank">https://github.com/lordmulder/LameXP/tree/master/etc/Translation</a><br>(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...")</p>
|
||||||
<p><font color="darkred"><b>Important:</b> Before you start translating, always make sure your download the <i>latest</i> "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 <i>latest</i> 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.</font></p>
|
<p><font color="darkred"><b>Important:</b> Before you start translating, always make sure your download the <i>latest</i> "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 <i>latest</i> 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.</font></p>
|
||||||
<br>
|
<br>
|
||||||
<h3>Language file editing rules:</h3>
|
<h3>Language file editing rules:</h3>
|
||||||
|
@ -462,6 +462,10 @@
|
|||||||
<source>Show DropBox</source>
|
<source>Show DropBox</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>From File...</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>Adding file(s), please wait...</source>
|
<source>Adding file(s), please wait...</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
@ -674,6 +678,14 @@
|
|||||||
<source>Add folder</source>
|
<source>Add folder</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Load Translation</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Translation Files</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>New Folder</source>
|
<source>New Folder</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
|
@ -831,6 +831,18 @@
|
|||||||
<source>No</source>
|
<source>No</source>
|
||||||
<translation>Nein</translation>
|
<translation>Nein</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>From File...</source>
|
||||||
|
<translation>Von Datei...</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Load Translation</source>
|
||||||
|
<translation>Übersetzung Laden</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Translation Files</source>
|
||||||
|
<translation>Übersetzungsdateien</translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>MetaInfo</name>
|
<name>MetaInfo</name>
|
||||||
|
@ -1229,6 +1229,7 @@
|
|||||||
<iconset resource="../res/Icons.qrc">
|
<iconset resource="../res/Icons.qrc">
|
||||||
<normaloff>:/icons/font.png</normaloff>:/icons/font.png</iconset>
|
<normaloff>:/icons/font.png</normaloff>:/icons/font.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
|
<addaction name="actionLoadTranslationFromFile"/>
|
||||||
</widget>
|
</widget>
|
||||||
<addaction name="actionSourceFiles"/>
|
<addaction name="actionSourceFiles"/>
|
||||||
<addaction name="actionOutputDirectory"/>
|
<addaction name="actionOutputDirectory"/>
|
||||||
@ -1476,6 +1477,15 @@
|
|||||||
<string notr="true">English</string>
|
<string notr="true">English</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionLoadTranslationFromFile">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../res/Icons.qrc">
|
||||||
|
<normaloff>:/icons/folder_page.png</normaloff>:/icons/folder_page.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>From File...</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../res/Icons.qrc"/>
|
<include location="../res/Icons.qrc"/>
|
||||||
@ -1489,6 +1499,10 @@
|
|||||||
<include location="../res/Images.qrc"/>
|
<include location="../res/Images.qrc"/>
|
||||||
<include location="../res/Icons.qrc"/>
|
<include location="../res/Icons.qrc"/>
|
||||||
<include location="../res/Images.qrc"/>
|
<include location="../res/Images.qrc"/>
|
||||||
|
<include location="../res/Icons.qrc"/>
|
||||||
|
<include location="../res/Images.qrc"/>
|
||||||
|
<include location="../res/Icons.qrc"/>
|
||||||
|
<include location="../res/Images.qrc"/>
|
||||||
</resources>
|
</resources>
|
||||||
<connections>
|
<connections>
|
||||||
<connection>
|
<connection>
|
||||||
|
Binary file not shown.
@ -25,7 +25,7 @@
|
|||||||
#define VER_LAMEXP_MAJOR 4
|
#define VER_LAMEXP_MAJOR 4
|
||||||
#define VER_LAMEXP_MINOR_HI 0
|
#define VER_LAMEXP_MINOR_HI 0
|
||||||
#define VER_LAMEXP_MINOR_LO 0
|
#define VER_LAMEXP_MINOR_LO 0
|
||||||
#define VER_LAMEXP_BUILD 217
|
#define VER_LAMEXP_BUILD 218
|
||||||
#define VER_LAMEXP_SUFFIX TechPreview
|
#define VER_LAMEXP_SUFFIX TechPreview
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -250,19 +250,21 @@ MainWindow::MainWindow(FileListModel *fileListModel, AudioFileModel *metaInfo, S
|
|||||||
|
|
||||||
//Populate the language menu
|
//Populate the language menu
|
||||||
m_languageActionGroup = new QActionGroup(this);
|
m_languageActionGroup = new QActionGroup(this);
|
||||||
connect(m_languageActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(languageActionActivated(QAction*)));
|
|
||||||
QStringList translations = lamexp_query_translations();
|
QStringList translations = lamexp_query_translations();
|
||||||
while(!translations.isEmpty())
|
while(!translations.isEmpty())
|
||||||
{
|
{
|
||||||
QString langId = translations.takeFirst();
|
QString langId = translations.takeLast();
|
||||||
QAction *currentLanguage = new QAction(this);
|
QAction *currentLanguage = new QAction(this);
|
||||||
currentLanguage->setData(langId);
|
currentLanguage->setData(langId);
|
||||||
currentLanguage->setText(lamexp_translation_name(langId));
|
currentLanguage->setText(lamexp_translation_name(langId));
|
||||||
currentLanguage->setIcon(QIcon(QString(":/flags/%1.png").arg(langId)));
|
currentLanguage->setIcon(QIcon(QString(":/flags/%1.png").arg(langId)));
|
||||||
currentLanguage->setCheckable(true);
|
currentLanguage->setCheckable(true);
|
||||||
m_languageActionGroup->addAction(currentLanguage);
|
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
|
//Activate tools menu actions
|
||||||
actionDisableUpdateReminder->setChecked(!m_settings->autoUpdateEnabled());
|
actionDisableUpdateReminder->setChecked(!m_settings->autoUpdateEnabled());
|
||||||
@ -1039,11 +1041,42 @@ void MainWindow::styleActionActivated(QAction *action)
|
|||||||
*/
|
*/
|
||||||
void MainWindow::languageActionActivated(QAction *action)
|
void MainWindow::languageActionActivated(QAction *action)
|
||||||
{
|
{
|
||||||
QString langId = action->data().toString();
|
if(action->data().type() == QVariant::String)
|
||||||
|
|
||||||
if(lamexp_install_translator(langId))
|
|
||||||
{
|
{
|
||||||
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<QAction*> actions = m_languageActionGroup->actions();
|
||||||
|
while(!actions.isEmpty())
|
||||||
|
{
|
||||||
|
actions.takeFirst()->setChecked(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
languageActionActivated(m_languageActionGroup->actions().first());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,6 +61,7 @@ private slots:
|
|||||||
void tabActionActivated(QAction *action);
|
void tabActionActivated(QAction *action);
|
||||||
void styleActionActivated(QAction *action);
|
void styleActionActivated(QAction *action);
|
||||||
void languageActionActivated(QAction *action);
|
void languageActionActivated(QAction *action);
|
||||||
|
void languageFromFileActionActivated(bool checked);
|
||||||
void outputFolderViewClicked(const QModelIndex &index);
|
void outputFolderViewClicked(const QModelIndex &index);
|
||||||
void outputFolderViewMoved(const QModelIndex &index);
|
void outputFolderViewMoved(const QModelIndex &index);
|
||||||
void makeFolderButtonClicked(void);
|
void makeFolderButtonClicked(void);
|
||||||
|
@ -917,24 +917,16 @@ bool lamexp_install_translator(const QString &langId)
|
|||||||
{
|
{
|
||||||
bool success = false;
|
bool success = false;
|
||||||
|
|
||||||
if(!g_lamexp_currentTranslator)
|
|
||||||
{
|
|
||||||
g_lamexp_currentTranslator = new QTranslator();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(langId.isEmpty() || langId.toLower().compare(LAMEXP_DEFAULT_LANGID) == 0)
|
if(langId.isEmpty() || langId.toLower().compare(LAMEXP_DEFAULT_LANGID) == 0)
|
||||||
{
|
{
|
||||||
QApplication::removeTranslator(g_lamexp_currentTranslator);
|
success = lamexp_install_translator_from_file(QString());
|
||||||
success = true;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QString qmFile = g_lamexp_translation_files.value(langId.toLower(), QString());
|
QString qmFile = g_lamexp_translation_files.value(langId.toLower(), QString());
|
||||||
if(!qmFile.isEmpty())
|
if(!qmFile.isEmpty())
|
||||||
{
|
{
|
||||||
QApplication::removeTranslator(g_lamexp_currentTranslator);
|
success = lamexp_install_translator_from_file(QString(":/localization/%1").arg(qmFile));
|
||||||
success = g_lamexp_currentTranslator->load(QString(":/localization/%1").arg(qmFile));
|
|
||||||
QApplication::installTranslator(g_lamexp_currentTranslator);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -945,6 +937,38 @@ bool lamexp_install_translator(const QString &langId)
|
|||||||
return success;
|
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
|
* Locate known folder on local system
|
||||||
*/
|
*/
|
||||||
|
@ -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);
|
bool lamexp_translation_register(const QString &langId, const QString &qmFile, const QString &langName, unsigned int &systemId);
|
||||||
QString lamexp_translation_name(const QString &language);
|
QString lamexp_translation_name(const QString &language);
|
||||||
unsigned int lamexp_translation_sysid(const QString &langId);
|
unsigned int lamexp_translation_sysid(const QString &langId);
|
||||||
|
bool lamexp_install_translator_from_file(const QString &qmFile);
|
||||||
bool lamexp_install_translator(const QString &language);
|
bool lamexp_install_translator(const QString &language);
|
||||||
static const char* LAMEXP_DEFAULT_LANGID = "en";
|
static const char* LAMEXP_DEFAULT_LANGID = "en";
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user