mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-10-18 17:24:01 -04:00
launcher: stop rebuilding the category map per app and index i18n misses
fixes #3345
port 1.6
(cherry picked from commit c76c29139f)
This commit is contained in:
@@ -189,6 +189,26 @@ Singleton {
|
||||
}
|
||||
}
|
||||
|
||||
readonly property var _termIndexes: new WeakMap()
|
||||
|
||||
function _termIndex(table) {
|
||||
const cached = _termIndexes.get(table);
|
||||
if (cached)
|
||||
return cached;
|
||||
const index = {};
|
||||
for (const c in table) {
|
||||
const bucket = table[c];
|
||||
if (!bucket)
|
||||
continue;
|
||||
for (const term in bucket) {
|
||||
if (!index[term] && bucket[term])
|
||||
index[term] = bucket[term];
|
||||
}
|
||||
}
|
||||
_termIndexes.set(table, index);
|
||||
return index;
|
||||
}
|
||||
|
||||
function _lookup(table, term, context) {
|
||||
if (!table)
|
||||
return "";
|
||||
@@ -196,11 +216,7 @@ Singleton {
|
||||
return table[context][term];
|
||||
if (table[term] && table[term][term])
|
||||
return table[term][term];
|
||||
for (const c in table) {
|
||||
if (table[c] && table[c][term])
|
||||
return table[c][term];
|
||||
}
|
||||
return "";
|
||||
return _termIndex(table)[term] || "";
|
||||
}
|
||||
|
||||
// isRealContext is consumed by translations/extract_translations.py only:
|
||||
|
||||
@@ -769,11 +769,7 @@ Singleton {
|
||||
return results;
|
||||
}
|
||||
|
||||
function getCategoriesForApp(app) {
|
||||
if (!app?.categories)
|
||||
return [];
|
||||
|
||||
const categoryMap = {
|
||||
readonly property var _categoryMap: ({
|
||||
"AudioVideo": I18n.tr("Media"),
|
||||
"Audio": I18n.tr("Media"),
|
||||
"Video": I18n.tr("Media"),
|
||||
@@ -798,15 +794,20 @@ Singleton {
|
||||
"Accessories": I18n.tr("Utilities"),
|
||||
"FileManager": I18n.tr("Utilities"),
|
||||
"TerminalEmulator": I18n.tr("Utilities")
|
||||
};
|
||||
})
|
||||
|
||||
on_CategoryMapChanged: _cachedCategories = null
|
||||
|
||||
function getCategoriesForApp(app) {
|
||||
if (!app?.categories)
|
||||
return [];
|
||||
|
||||
const mappedCategories = new Set();
|
||||
|
||||
for (const cat of app.categories) {
|
||||
if (categoryMap[cat])
|
||||
mappedCategories.add(categoryMap[cat]);
|
||||
const mapped = _categoryMap[cat];
|
||||
if (mapped)
|
||||
mappedCategories.add(mapped);
|
||||
}
|
||||
|
||||
return Array.from(mappedCategories);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user