Permalink
Browse files

make more strings translatable + try to load a default translation th…

…at suits the user's system language
  • Loading branch information...
1 parent 5a1ff67 commit 8c0fa11803587b661957da713b29c2ebb2282a46 @lordmulder committed Jan 2, 2011
View
@@ -1211,6 +1211,36 @@
<File
RelativePath=".\src\Registry_Decoder.h"
>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="MOC &quot;$(SolutionDir)tmp\MOC_$(SafeInputName).cpp&quot;"
+ CommandLine="&quot;$(QTDIR)\bin\moc.exe&quot; -o &quot;$(SolutionDir)tmp\MOC_$(SafeInputName).cpp&quot; &quot;$(InputPath)&quot;"
+ Outputs="&quot;$(SolutionDir)tmp\MOC_$(SafeInputName).cpp&quot;"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="MOC &quot;$(SolutionDir)tmp\MOC_$(SafeInputName).cpp&quot;"
+ CommandLine="&quot;$(QTDIR)\bin\moc.exe&quot; -o &quot;$(SolutionDir)tmp\MOC_$(SafeInputName).cpp&quot; &quot;$(InputPath)&quot;"
+ Outputs="&quot;$(SolutionDir)tmp\MOC_$(SafeInputName).cpp&quot;"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release_Static|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="MOC &quot;$(SolutionDir)tmp\MOC_$(SafeInputName).cpp&quot;"
+ CommandLine="&quot;$(QTDIR)\bin\moc.exe&quot; -o &quot;$(SolutionDir)tmp\MOC_$(SafeInputName).cpp&quot; &quot;$(InputPath)&quot;"
+ Outputs="&quot;$(SolutionDir)tmp\MOC_$(SafeInputName).cpp&quot;"
+ />
+ </FileConfiguration>
</File>
<File
RelativePath=".\src\Resource.h"
@@ -1515,6 +1545,10 @@
>
</File>
<File
+ RelativePath=".\tmp\MOC_Registry_Decoder.cpp"
+ >
+ </File>
+ <File
RelativePath=".\tmp\MOC_Thread_FileAnalyzer.cpp"
>
</File>
@@ -1676,7 +1710,7 @@
>
<Tool
Name="VCCustomBuildTool"
- CommandLine="&quot;$(QTDIR)\bin\rcc.exe&quot; -o &quot;$(SolutionDir)tmp\RCC_$(SafeInputName).cpp&quot; -name &quot;$(SafeInputName)&quot; &quot;$(InputPath)&quot;"
+ CommandLine="&quot;$(QTDIR)\bin\rcc.exe&quot; -o &quot;$(SolutionDir)tmp\RCC_$(SafeInputName).cpp&quot; -name &quot;$(SafeInputName)&quot; &quot;$(InputPath)&quot;&#x0D;&#x0A;"
AdditionalDependencies="RCC &quot;$(SolutionDir)tmp\RCC_$(SafeInputName).cpp&quot;"
Outputs="&quot;$(SolutionDir)tmp\RCC_$(SafeInputName).cpp&quot;"
/>
@@ -1686,7 +1720,7 @@
>
<Tool
Name="VCCustomBuildTool"
- CommandLine="&quot;$(QTDIR)\bin\rcc.exe&quot; -o &quot;$(SolutionDir)tmp\RCC_$(SafeInputName).cpp&quot; -name &quot;$(SafeInputName)&quot; &quot;$(InputPath)&quot;"
+ CommandLine="&quot;$(QTDIR)\bin\rcc.exe&quot; -o &quot;$(SolutionDir)tmp\RCC_$(SafeInputName).cpp&quot; -name &quot;$(SafeInputName)&quot; &quot;$(InputPath)&quot;&#x0D;&#x0A;"
AdditionalDependencies="RCC &quot;$(SolutionDir)tmp\RCC_$(SafeInputName).cpp&quot;"
Outputs="&quot;$(SolutionDir)tmp\RCC_$(SafeInputName).cpp&quot;"
/>
@@ -1696,7 +1730,7 @@
>
<Tool
Name="VCCustomBuildTool"
- CommandLine="&quot;$(QTDIR)\bin\rcc.exe&quot; -o &quot;$(SolutionDir)tmp\RCC_$(SafeInputName).cpp&quot; -name &quot;$(SafeInputName)&quot; &quot;$(InputPath)&quot;"
+ CommandLine="&quot;$(QTDIR)\bin\rcc.exe&quot; -o &quot;$(SolutionDir)tmp\RCC_$(SafeInputName).cpp&quot; -name &quot;$(SafeInputName)&quot; &quot;$(InputPath)&quot;&#x0D;&#x0A;"
AdditionalDependencies="RCC &quot;$(SolutionDir)tmp\RCC_$(SafeInputName).cpp&quot;"
Outputs="&quot;$(SolutionDir)tmp\RCC_$(SafeInputName).cpp&quot;"
/>
@@ -37,6 +37,12 @@ del /Q "%OBJ_PATH%\*.idb"
del /Q "%MOC_PATH%\*.cpp"
del /Q "%MOC_PATH%\*.h"
REM ------------------------------------------
+REM :: BUILD LANGUAGE FILES ::
+REM ------------------------------------------
+for %%f in (..\Translation\*.ts) do (
+ lrelease.exe %%f -qm ..\..\res\localization\%%~nf.qm
+)
+REM ------------------------------------------
REM :: BUILD BINARIES ::
REM ------------------------------------------
call _build.bat "..\..\LameXP.sln" "%LAMEXP_CONFIG%"
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
@@ -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 204
+#define VER_LAMEXP_BUILD 209
#define VER_LAMEXP_SUFFIX TechPreview
/*
@@ -190,14 +190,14 @@ void AboutDialog::showAboutQt(void)
void AboutDialog::showAboutContributors(void)
{
QString contributorsAboutText;
- contributorsAboutText += QString("<h3>%1</h3>").arg(tr("The following people have contributed to LameXP:"));
+ contributorsAboutText += QString("<h3><nobr>%1</nobr></h3>").arg(tr("The following people have contributed to LameXP:"));
contributorsAboutText += QString("<b>%1</b>").arg(tr("Translators:"));
contributorsAboutText += "<table style=\"margin-top:5px\">";
- contributorsAboutText += CONTRIBUTOR("Englisch", "LoRd_MuldeR &lt;MuldeR2@GMX.de&gt;", ":/flags/gb.png");
+ contributorsAboutText += CONTRIBUTOR("Englisch", "LoRd_MuldeR &lt;MuldeR2@GMX.de&gt;", ":/flags/en.png");
contributorsAboutText += CONTRIBUTOR("Deutsch", "LoRd_MuldeR &lt;MuldeR2@GMX.de&gt;", ":/flags/de.png");
contributorsAboutText += "</table>";
contributorsAboutText += "<br><br>";
- contributorsAboutText += QString("<i>%1</i><br>").arg(tr("If you are willing to contribute a LameXP translation, feel free to contact us!"));
+ contributorsAboutText += QString("<nobr><i>%1</i></nobr><br>").arg(tr("If you are willing to contribute a LameXP translation, feel free to contact us!"));
QMessageBox *contributorsAboutBox = new QMessageBox(this);
contributorsAboutBox->setText(contributorsAboutText);
@@ -599,7 +599,7 @@ void MainWindow::windowShown(void)
{
qWarning("Binary has expired !!!");
PlaySound(MAKEINTRESOURCE(IDR_WAVE_WHAMMY), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC);
- if(QMessageBox::warning(this, tr("LameXP - Expired"), tr("This demo (pre-release) version of LameXP has expired at %1.\nLameXP is free software and release versions won't expire.").arg(expireDate.toString(Qt::ISODate)), tr("Check for Updates"), tr("Exit Program")) == 0)
+ if(QMessageBox::warning(this, tr("LameXP - Expired"), QString("<nobr>%1<br>%2</nobr>").arg(tr("This demo (pre-release) version of LameXP has expired at %1.").arg(expireDate.toString(Qt::ISODate)), tr("LameXP is free software and release versions won't expire.")), tr("Check for Updates"), tr("Exit Program")) == 0)
{
checkUpdatesActionActivated();
}
@@ -627,7 +627,7 @@ void MainWindow::windowShown(void)
QDate lastUpdateCheck = QDate::fromString(m_settings->autoUpdateLastCheck(), Qt::ISODate);
if(!lastUpdateCheck.isValid() || QDate::currentDate() >= lastUpdateCheck.addDays(14))
{
- if(QMessageBox::information(this, tr("Update Reminer"), (lastUpdateCheck.isValid() ? tr("Your last update check was more than 14 days ago. Check for updates now?") : tr("Your did not check for LameXP updates yet. Check for updates now?")), tr("Check for Updates"), tr("Postpone")) == 0)
+ if(QMessageBox::information(this, tr("Update Reminder"), (lastUpdateCheck.isValid() ? tr("Your last update check was more than 14 days ago. Check for updates now?") : tr("Your did not check for LameXP updates yet. Check for updates now?")), tr("Check for Updates"), tr("Postpone")) == 0)
{
checkUpdatesActionActivated();
}
@@ -1214,7 +1214,7 @@ void MainWindow::notifyOtherInstance(void)
{
if(!m_banner->isVisible())
{
- QMessageBox msgBox(QMessageBox::Warning, tr("Already running"), tr("LameXP is already running, please use the running instance!"), QMessageBox::NoButton, this, Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint | Qt::WindowStaysOnTopHint);
+ QMessageBox msgBox(QMessageBox::Warning, tr("Already Running"), tr("LameXP is already running, please use the running instance!"), QMessageBox::NoButton, this, Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint | Qt::WindowStaysOnTopHint);
msgBox.exec();
}
}
@@ -114,7 +114,7 @@ ProcessingDialog::ProcessingDialog(FileListModel *fileListModel, AudioFileModel
//Create context menu
m_contextMenu = new QMenu();
- QAction *contextMenuAction = m_contextMenu->addAction(QIcon(":/icons/zoom.png"), "Show details for selected job");
+ QAction *contextMenuAction = m_contextMenu->addAction(QIcon(":/icons/zoom.png"), tr("Show details for selected job"));
view_log->setContextMenuPolicy(Qt::CustomContextMenu);
connect(view_log, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuTriggered(QPoint)));
connect(contextMenuAction, SIGNAL(triggered(bool)), this, SLOT(contextMenuActionTriggered()));
@@ -243,7 +243,7 @@ void ProcessingDialog::initEncoding(void)
m_playList.clear();
CHANGE_BACKGROUND_COLOR(frame_header, QColor(Qt::white));
- SET_PROGRESS_TEXT("Encoding files, please wait...");
+ SET_PROGRESS_TEXT(tr("Encoding files, please wait..."));
m_progressIndicator->start();
button_closeDialog->setEnabled(false);
@@ -268,7 +268,7 @@ void ProcessingDialog::abortEncoding(void)
m_userAborted = true;
button_AbortProcess->setEnabled(false);
- SET_PROGRESS_TEXT("Aborted! Waiting for running jobs to terminate...");
+ SET_PROGRESS_TEXT(tr("Aborted! Waiting for running jobs to terminate..."));
for(int i = 0; i < m_threadList.count(); i++)
{
@@ -283,7 +283,7 @@ void ProcessingDialog::doneEncoding(void)
if(!m_userAborted)
{
- SET_PROGRESS_TEXT(QString("Encoding: %1 files of %2 completed so far, please wait...").arg(QString::number(progressBar->value()), QString::number(progressBar->maximum())));
+ SET_PROGRESS_TEXT(tr("Encoding: %1 files of %2 completed so far, please wait...").arg(QString::number(progressBar->value()), QString::number(progressBar->maximum())));
WinSevenTaskbar::setTaskbarProgress(this, progressBar->value(), progressBar->maximum());
}
@@ -311,7 +311,7 @@ void ProcessingDialog::doneEncoding(void)
if(!m_userAborted && m_settings->createPlaylist() && !m_settings->outputToSourceDir())
{
- SET_PROGRESS_TEXT("Creatig the playlist file, please wait...");
+ SET_PROGRESS_TEXT(tr("Creatig the playlist file, please wait..."));
QApplication::processEvents();
writePlayList();
}
@@ -321,8 +321,8 @@ void ProcessingDialog::doneEncoding(void)
CHANGE_BACKGROUND_COLOR(frame_header, QColor("#FFF3BA"));
WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarErrorState);
WinSevenTaskbar::setOverlayIcon(this, &QIcon(":/icons/error.png"));
- SET_PROGRESS_TEXT((m_succeededJobs.count() > 0) ? QString("Process was aborted by the user after %1 file(s)!").arg(QString::number(m_succeededJobs.count())) : "Process was aborted prematurely by the user!");
- m_systemTray->showMessage("LameXP - Aborted", "Process was aborted by the user.", QSystemTrayIcon::Warning);
+ SET_PROGRESS_TEXT((m_succeededJobs.count() > 0) ? tr("Process was aborted by the user after %1 file(s)!").arg(QString::number(m_succeededJobs.count())) : "Process was aborted prematurely by the user!");
+ m_systemTray->showMessage(tr("LameXP - Aborted"), tr("Process was aborted by the user."), QSystemTrayIcon::Warning);
m_systemTray->setIcon(QIcon(":/icons/cd_delete.png"));
QApplication::processEvents();
if(m_settings->soundsEnabled()) PlaySound(MAKEINTRESOURCE(IDR_WAVE_ABORTED), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC);
@@ -334,8 +334,8 @@ void ProcessingDialog::doneEncoding(void)
CHANGE_BACKGROUND_COLOR(frame_header, QColor("#FFBABA"));
WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarErrorState);
WinSevenTaskbar::setOverlayIcon(this, &QIcon(":/icons/exclamation.png"));
- SET_PROGRESS_TEXT(QString("Error: %1 of %2 files failed. Double-click failed items for detailed information!").arg(QString::number(m_failedJobs.count()), QString::number(m_failedJobs.count() + m_succeededJobs.count())));
- m_systemTray->showMessage("LameXP - Error", "At least one file has failed!", QSystemTrayIcon::Critical);
+ SET_PROGRESS_TEXT(tr("Error: %1 of %2 files failed. Double-click failed items for detailed information!").arg(QString::number(m_failedJobs.count()), QString::number(m_failedJobs.count() + m_succeededJobs.count())));
+ m_systemTray->showMessage(tr("LameXP - Error"), tr("At least one file has failed!"), QSystemTrayIcon::Critical);
m_systemTray->setIcon(QIcon(":/icons/cd_delete.png"));
QApplication::processEvents();
if(m_settings->soundsEnabled()) PlaySound(MAKEINTRESOURCE(IDR_WAVE_ERROR), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC);
@@ -345,8 +345,8 @@ void ProcessingDialog::doneEncoding(void)
CHANGE_BACKGROUND_COLOR(frame_header, QColor("#E0FFE2"));
WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarNormalState);
WinSevenTaskbar::setOverlayIcon(this, &QIcon(":/icons/accept.png"));
- SET_PROGRESS_TEXT("Alle files completed successfully.");
- m_systemTray->showMessage("LameXP - Done", "All files completed successfully.", QSystemTrayIcon::Information);
+ SET_PROGRESS_TEXT(tr("Alle files completed successfully."));
+ m_systemTray->showMessage(tr("LameXP - Done"), tr("All files completed successfully."), QSystemTrayIcon::Information);
m_systemTray->setIcon(QIcon(":/icons/cd_add.png"));
QApplication::processEvents();
if(m_settings->soundsEnabled()) PlaySound(MAKEINTRESOURCE(IDR_WAVE_SUCCESS), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC);
@@ -535,7 +535,7 @@ void ProcessingDialog::writePlayList(void)
}
else
{
- QMessageBox::warning(this, "Playlist creation failed", QString("The playlist file could not be created:<br><nobr>%1</nobr>").arg(playListFile));
+ QMessageBox::warning(this, tr("Playlist creation failed"), QString("%1<br><nobr>%2</nobr>").arg(tr("The playlist file could not be created:"), playListFile));
}
}
View
@@ -123,6 +123,7 @@ static QMap<QString, unsigned int> g_lamexp_tool_versions;
//Languages
static QMap<QString, QString> g_lamexp_translation_files;
static QMap<QString, QString> g_lamexp_translation_names;
+static QMap<QString, WORD> g_lamexp_translation_sysid;
static QTranslator *g_lamexp_currentTranslator = NULL;
//Shared memory
@@ -465,24 +466,31 @@ static void lamexp_init_translations(void)
while(!qmFiles.isEmpty())
{
QString langId, langName;
+ WORD systemId = 0;
QString qmFile = qmFiles.takeFirst();
-
+
QRegExp langIdExp("LameXP_(\\w\\w)\\.qm", Qt::CaseInsensitive);
if(langIdExp.indexIn(qmFile) >= 0)
{
langId = langIdExp.cap(1).toLower();
}
-
- QResource langNameRes = (QString(":/localization/%1.txt").arg(qmFile));
- if(langNameRes.isValid() && langNameRes.size() > 0)
+
+ QResource langRes = (QString(":/localization/%1.txt").arg(qmFile));
+ if(langRes.isValid() && langRes.size() > 0)
{
- langName = QString::fromUtf8(reinterpret_cast<const char*>(langNameRes.data()), langNameRes.size());
+ QStringList langInfo = QString::fromUtf8(reinterpret_cast<const char*>(langRes.data()), langRes.size()).simplified().split(",", QString::SkipEmptyParts);
+ if(langInfo.count() == 2)
+ {
+ systemId = langInfo.at(0).toUInt();
+ langName = langInfo.at(1);
+ }
}
- if(!langId.isEmpty() && !langName.isEmpty())
+ if(!langId.isEmpty() && systemId > 0 && !langName.isEmpty())
{
g_lamexp_translation_files.insert(langId, qmFile);
g_lamexp_translation_names.insert(langId, langName);
+ g_lamexp_translation_sysid.insert(langId, systemId);
}
}
}
@@ -908,6 +916,14 @@ QString lamexp_translation_name(const QString &langId)
}
/*
+ * Get translation system id
+ */
+WORD lamexp_translation_sysid(const QString &langId)
+{
+ return g_lamexp_translation_sysid.value(langId.toLower(), 0);
+}
+
+/*
* Install a new translator
*/
bool lamexp_install_translator(const QString &langId)
View
@@ -95,8 +95,9 @@ lamexp_cpu_t lamexp_detect_cpu_features(void);
//Translation support
QStringList lamexp_query_translations(void);
QString lamexp_translation_name(const QString &language);
+WORD lamexp_translation_sysid(const QString &langId);
bool lamexp_install_translator(const QString &language);
-static const char* LAMEXP_DEFAULT_LANGID = "gb";
+static const char* LAMEXP_DEFAULT_LANGID = "en";
//Auxiliary functions
bool lamexp_clean_folder(const QString folderPath);
@@ -100,10 +100,10 @@ QVariant ProgressModel::headerData(int section, Qt::Orientation orientation, int
switch(section)
{
case 0:
- return "Job";
+ return tr("Job");
break;
case 1:
- return "Status";
+ return tr("Status");
break;
default:
return QVariant();
@@ -70,6 +70,8 @@ const int SettingsModel::mp3Bitrates[15] = {32, 40, 48, 56, 64, 80, 96, 112, 128
////////////////////////////////////////////////////////////
SettingsModel::SettingsModel(void)
+:
+ m_defaultLanguage(NULL)
{
QString appPath = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
m_settings = new QSettings(appPath.append("/config.ini"), QSettings::IniFormat);
@@ -85,6 +87,7 @@ SettingsModel::SettingsModel(void)
SettingsModel::~SettingsModel(void)
{
LAMEXP_DELETE(m_settings);
+ LAMEXP_DELETE(m_defaultLanguage);
}
////////////////////////////////////////////////////////////
@@ -120,11 +123,47 @@ void SettingsModel::validate(void)
if(!lamexp_query_translations().contains(this->currentLanguage(), Qt::CaseInsensitive))
{
qWarning("Current language is unknown, reverting to default language!");
- this->currentLanguage(LAMEXP_DEFAULT_LANGID);
+ this->currentLanguage(defaultLanguage());
}
}
////////////////////////////////////////////////////////////
+// Private Functions
+////////////////////////////////////////////////////////////
+
+QString SettingsModel::defaultLanguage(void)
+{
+ if(m_defaultLanguage)
+ {
+ return *m_defaultLanguage;
+ }
+
+ //Check if we can use the default translation
+ WORD systemLangId = PRIMARYLANGID(GetUserDefaultLangID());
+ if(systemLangId == LANG_ENGLISH)
+ {
+ m_defaultLanguage = new QString(LAMEXP_DEFAULT_LANGID);
+ return LAMEXP_DEFAULT_LANGID;
+ }
+
+ //Try to find a suitable translation for the user's system language
+ QStringList languages = lamexp_query_translations();
+ while(!languages.isEmpty())
+ {
+ QString currentLangId = languages.takeFirst();
+ if(lamexp_translation_sysid(currentLangId) == systemLangId)
+ {
+ m_defaultLanguage = new QString(currentLangId);
+ return currentLangId;
+ }
+ }
+
+ //Fall back to the default translation
+ m_defaultLanguage = new QString(LAMEXP_DEFAULT_LANGID);
+ return LAMEXP_DEFAULT_LANGID;
+}
+
+////////////////////////////////////////////////////////////
// Getter and Setter
////////////////////////////////////////////////////////////
@@ -144,4 +183,4 @@ MAKE_OPTION3(soundsEnabled, true)
MAKE_OPTION3(neroAacNotificationsEnabled, true)
MAKE_OPTION3(wmaDecoderNotificationsEnabled, true)
MAKE_OPTION3(dropBoxWidgetEnabled, true)
-MAKE_OPTION2(currentLanguage, LAMEXP_DEFAULT_LANGID);
+MAKE_OPTION2(currentLanguage, defaultLanguage());
@@ -85,6 +85,8 @@ class SettingsModel
private:
QSettings *m_settings;
+ QString *m_defaultLanguage;
+ QString defaultLanguage(void);
};
#undef MAKE_OPTION_DEC1
Oops, something went wrong. Retry.

0 comments on commit 8c0fa11

Please sign in to comment.