Commit 358e98a7 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

emojier: improve the fallback mechanism to detect languages

- try to find the exact locale.
- Include the more generic one.
- If none were found, use English.

BUG: 417713
parent c92e4845
......@@ -133,18 +133,17 @@ public:
EmojiModel() {
QLocale locale;
QVector<QString> dicts;
const auto bcp = locale.bcp47Name();
const QString dictName = "ibus/dicts/emoji-" + QString(bcp).replace(QLatin1Char('-'), QLatin1Char('_')) + ".dict";
const QString path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, dictName);
if (path.isEmpty()) {
qWarning() << "could not find" << dictName;
return;
if (!path.isEmpty()) {
dicts << path;
}
QVector<QString> dicts = {path};
const auto idxSpecific = bcp.indexOf(QLatin1Char('-'));
if (idxSpecific > 0) {
const QString genericDictName = "ibus/dicts/emoji-" + bcp.left(idxSpecific) + ".dict";
const QString genericDictName = "ibus/dicts/emoji-" + bcp.leftRef(idxSpecific) + ".dict";
const QString genericPath = QStandardPaths::locate(QStandardPaths::GenericDataLocation, genericDictName);
if (!genericPath.isEmpty()) {
......@@ -152,6 +151,20 @@ public:
}
}
if (dicts.isEmpty()) {
const QString genericDictName = "ibus/dicts/emoji-en.dict";
const QString genericPath = QStandardPaths::locate(QStandardPaths::GenericDataLocation, genericDictName);
if (!genericPath.isEmpty()) {
dicts << genericPath;
}
}
if (dicts.isEmpty()) {
qWarning() << "could not find ibus emoji dictionaries." << dictName;
return;
}
QSet<QString> categories;
QSet<QString> processedEmoji;
for (const auto &dictPath : qAsConst(dicts)) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment