Skip to content
This repository has been archived by the owner on Sep 4, 2021. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'mer1664' into 'master'
[libcontacts] Load decomposition translations. Contributes to MER#1664

Previously, we relied on the client application to load the translation
files prior to performing FN to N decomposition tokenisation.
This commit ensures that the translations are loaded by libcontacts.

Contributes to MER#1664

See merge request !4
  • Loading branch information
chriadam committed Oct 11, 2016
2 parents 342d98c + ca66201 commit c6f0e5d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/seasidecache.cpp
Expand Up @@ -509,6 +509,8 @@ int bestPhoneNumberMatchLength(const QContact &contact, const QString &match)
SeasideCache *SeasideCache::instancePtr = 0;
int SeasideCache::contactNameGroupCount = getContactNameGroupCount();
QStringList SeasideCache::allContactNameGroups = getAllContactNameGroups();
QTranslator *SeasideCache::engEnTranslator = 0;
QTranslator *SeasideCache::translator = 0;

QContactManager* SeasideCache::manager()
{
Expand Down Expand Up @@ -1215,6 +1217,15 @@ void updateNameDetail(F1 getter, F2 setter, QContactName *nameDetail, const QStr

void SeasideCache::decomposeDisplayLabel(const QString &formattedDisplayLabel, QContactName *nameDetail)
{
if (!translator) {
engEnTranslator = new QTranslator(qApp);
engEnTranslator->load(QString::fromLatin1("libcontacts_eng_en"), QString::fromLatin1("/usr/share/translations"));
qApp->installTranslator(engEnTranslator);
translator = new QTranslator(qApp);
translator->load(QLocale(), QString::fromLatin1("libcontacts"), QString::fromLatin1("-"), QString::fromLatin1("/usr/share/translations"));
qApp->installTranslator(translator);
}

// Try to parse the structure from the formatted name
// TODO: Use MBreakIterator for localized splitting
QStringList tokens(formattedDisplayLabel.split(QChar::fromLatin1(' '), QString::SkipEmptyParts));
Expand Down
3 changes: 3 additions & 0 deletions src/seasidecache.h
Expand Up @@ -52,6 +52,7 @@
#include <QContactIdFetchRequest>
#include <QContactName>

#include <QTranslator>
#include <QBasicTimer>
#include <QHash>
#include <QSet>
Expand Down Expand Up @@ -491,6 +492,8 @@ private slots:
static SeasideCache *instancePtr;
static int contactNameGroupCount;
static QStringList allContactNameGroups;
static QTranslator *engEnTranslator;
static QTranslator *translator;

friend bool operator==(const SeasideCache::ResolveData &lhs, const SeasideCache::ResolveData &rhs);
friend uint qHash(const SeasideCache::ResolveData &key, uint seed);
Expand Down

0 comments on commit c6f0e5d

Please sign in to comment.