Allow for translated html texts

This commit is contained in:
Phil Olynyk 2019-03-20 09:49:17 -04:00
parent b0ef042e40
commit a57acf3211
3 changed files with 22 additions and 4 deletions

View File

@ -67,9 +67,24 @@ void AboutDialog::on_donateButton_clicked()
} }
******************************************************/ ******************************************************/
QString AboutDialog::getFilename(QString name)
{
QString filename;
QString language = AppSetting->language();
if (language == "en_US") {
filename = ":docs/"+name+".html";
} else {
QString docRoot = appResourcePath() + "/Html/";
filename = docRoot + name + language + "/Html/";
}
qDebug() << "Looking for " + filename;
return filename;
}
QString AboutDialog::getAbout() QString AboutDialog::getAbout()
{ {
QFile clfile(":/docs/about.html"); QString aboutFile = getFilename("about");
QFile clfile(aboutFile);
QString text = tr("Sorry, could not locate About file."); QString text = tr("Sorry, could not locate About file.");
if (clfile.open(QIODevice::ReadOnly)) { if (clfile.open(QIODevice::ReadOnly)) {
text = clfile.readAll(); text = clfile.readAll();
@ -81,7 +96,8 @@ QString AboutDialog::getAbout()
QString AboutDialog::getCredits() QString AboutDialog::getCredits()
{ {
QFile clfile(":/docs/credits.html"); QString creditsFile = getFilename("credits");
QFile clfile(creditsFile);
QString text = tr("Sorry, could not locate Credits file."); QString text = tr("Sorry, could not locate Credits file.");
if (clfile.open(QIODevice::ReadOnly)) { if (clfile.open(QIODevice::ReadOnly)) {
text = clfile.readAll(); text = clfile.readAll();
@ -92,7 +108,8 @@ QString AboutDialog::getCredits()
QString AboutDialog::getRelnotes() QString AboutDialog::getRelnotes()
{ {
QFile clfile(":/docs/release_notes.html"); QString relNotesFile = getFilename("release_notes");
QFile clfile(relNotesFile);
QString changeLog = tr("Sorry, could not locate Release Notes."); QString changeLog = tr("Sorry, could not locate Release Notes.");
if (clfile.open(QIODevice::ReadOnly)) { if (clfile.open(QIODevice::ReadOnly)) {
//Todo, write XML parser and only show the latest.. //Todo, write XML parser and only show the latest..

View File

@ -27,6 +27,7 @@ private slots:
void on_donateButton_clicked(); void on_donateButton_clicked();
***************************************************/ ***************************************************/
private: private:
QString getFilename(QString name);
QString getAbout(); QString getAbout();
QString getCredits(); QString getCredits();
QString getLicense(); QString getLicense();

View File

@ -1076,7 +1076,7 @@ QString MainWindow::getWelcomeHTML()
// + // +
"<p><h3>" + tr("Further Information") + "</h3></p>" "<p><h3>" + tr("Further Information") + "</h3></p>"
"<p>" + "<p>" +
tr("Here are the <a href='qrc:/docs/release_notes.html'>release notes</a> for this version.") + tr("The release notes for this version can be found in the About OSCAR menu item.") +
"<br/>" + "<br/>" +
tr("Plus a few <a href='qrc:/docs/usage.html'>usage notes</a>, and some important information for Mac users.") tr("Plus a few <a href='qrc:/docs/usage.html'>usage notes</a>, and some important information for Mac users.")
+ "<br/>" + + "<br/>" +