Skip to content

Commit

Permalink
Use KLocalizedString::languages() for language list
Browse files Browse the repository at this point in the history
If ki18n >= 5.20.0 is available, use KLocalizedString::languages()
to get the list of configured languages for translations.
This fixes the lookup of translated content, such as TOCs, mirroring
what was done with commit 37bc9831fe097b01bb100f622ecd0ef19f77b80f in
kio.git.
  • Loading branch information
Pino Toscano committed Mar 20, 2016
1 parent 568111a commit 734b150
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions docmetainfo.cpp
Expand Up @@ -29,6 +29,7 @@
#include "htmlsearch.h"
#include "docentrytraverser.h"
#include <KLocalizedString>
#include <ki18n_version.h>

using namespace KHC;

Expand Down Expand Up @@ -150,7 +151,11 @@ void DocMetaInfo::scanMetaInfo( bool force )
{
if ( mLoaded && !force ) return;

#if KI18N_VERSION >= QT_VERSION_CHECK(5, 20, 0)
QStringList langs = KLocalizedString::languages();
#else
QStringList langs = QLocale().uiLanguages();
#endif
mDefaultLanguage = langs.first();

QStringList::ConstIterator it;
Expand Down
5 changes: 5 additions & 0 deletions view.cpp
Expand Up @@ -12,6 +12,7 @@
#include <KHTMLSettings>
#include <KHTMLView>
#include <KToolBarPopupAction>
#include <ki18n_version.h>

#include <QFileInfo>
#include <QClipboard>
Expand Down Expand Up @@ -95,7 +96,11 @@ QString View::langLookup( const QString &fname )
// assemble the local search paths
const QStringList localDoc = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("doc/HTML"), QStandardPaths::LocateDirectory);

#if KI18N_VERSION >= QT_VERSION_CHECK(5, 20, 0)
QStringList langs = KLocalizedString::languages();
#else
QStringList langs = QLocale().uiLanguages();
#endif
langs.append(QStringLiteral("en"));
langs.removeAll(QStringLiteral("C"));

Expand Down

0 comments on commit 734b150

Please sign in to comment.