diff --git a/ChangeLog.txt b/ChangeLog.txt index 638bdae8f9..f29930b963 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,4 +1,4 @@ -pre-2.x.x +Sigil-pre-2.x.x New Features - assign menu accelerators P - &Plugins, and K - Chec&kpoints (thank you BeckyEbook) - add ability to change keyboard focus using keyboard shortcuts or menus @@ -17,6 +17,7 @@ pre-2.x.x - fix svg rendering in QtSvg by filtering out desc and title tags inside text tags pre-rendering - fix Python plugin quickparser.py to better handle svg mixed case tag names - better handle cancelling out of plugins prior to their completion + - better handle Guide/Landmark title translations (thank you BeckyEbook) Sigil-2.0.2 diff --git a/src/Misc/GuideItems.cpp b/src/Misc/GuideItems.cpp index b57622a6aa..92e6fd7db6 100644 --- a/src/Misc/GuideItems.cpp +++ b/src/Misc/GuideItems.cpp @@ -1,6 +1,6 @@ /************************************************************************ ** -** Copyright (C) 2016-2021 Kevin B. Hendricks, Stratford Ontario Canada +** Copyright (C) 2016-2023 Kevin B. Hendricks, Stratford Ontario Canada ** ** This file is part of Sigil. ** @@ -66,7 +66,7 @@ QString GuideItems::GetTitle(const QString &code, const QString &lang) // Note the book language may differ from the ui language bool translation_loaded = false; QTranslator bookTranslator; - const QString qm_name = QString("sigil_%1").arg(lang); + QString qm_name = QString("sigil_%1").arg(lang); // Run though all locations and stop once we find and are able to load // an appropriate translation. foreach(QString path, UILanguage::GetPossibleTranslationPaths()) { @@ -78,12 +78,24 @@ QString GuideItems::GetTitle(const QString &code, const QString &lang) } } } + // try again with just the base part of the langcode before any "-" + if (!translation_loaded && lang.contains("-")) { + const QString langcut = lang.split("-").at(0); + qm_name = QString("sigil_%1").arg(langcut); + foreach(QString path, UILanguage::GetPossibleTranslationPaths()) { + if (QDir(path).exists()) { + if (bookTranslator.load(qm_name, path)) { + translation_loaded = true; + break; + } + } + } + } // if no translator matched, use the user interface language so that // the dev can fix them manually if (!translation_loaded) { return GetName(code); } - QString title = bookTranslator.translate("GuideItems", m_CodeToRawTitle[code].toUtf8().constData()); if (title.isEmpty()) { title = bookTranslator.translate("Landmarks", m_CodeToRawTitle[code].toUtf8().constData()); diff --git a/src/Misc/Landmarks.cpp b/src/Misc/Landmarks.cpp index 01981d0e21..ca0b6c3153 100644 --- a/src/Misc/Landmarks.cpp +++ b/src/Misc/Landmarks.cpp @@ -1,6 +1,6 @@ /************************************************************************ ** -** Copyright (C) 2016-2020 Kevin B. Hendricks, Stratford, Ontario, Canada +** Copyright (C) 2016-2023 Kevin B. Hendricks, Stratford, Ontario, Canada ** ** This file is part of Sigil. ** @@ -63,7 +63,7 @@ QString Landmarks::GetTitle(const QString &code, const QString &lang) // Note the book language may differ from the ui language bool translation_loaded = false; QTranslator bookTranslator; - const QString qm_name = QString("sigil_%1").arg(lang); + QString qm_name = QString("sigil_%1").arg(lang); // Run though all locations and stop once we find and are able to load // an appropriate translation. foreach(QString path, UILanguage::GetPossibleTranslationPaths()) { @@ -74,12 +74,24 @@ QString Landmarks::GetTitle(const QString &code, const QString &lang) } } } + // try again with just the base part of the langcode before any "-" + if (!translation_loaded && lang.contains("-")) { + const QString langcut = lang.split("-").at(0); + qm_name = QString("sigil_%1").arg(langcut); + foreach(QString path, UILanguage::GetPossibleTranslationPaths()) { + if (QDir(path).exists()) { + if (bookTranslator.load(qm_name, path)) { + translation_loaded = true; + break; + } + } + } + } // if no translator matched, use the user interface language so that // the dev can fix them manually if (!translation_loaded) { return GetName(code); } - QString title = bookTranslator.translate("Landmarks", m_CodeToRawTitle[code].toUtf8().constData()); return title; }