From 6c59231f435c9175c3f93413ff9996c04a10d1cd Mon Sep 17 00:00:00 2001
From: Ali <010109ali@gmail.com>
Date: Tue, 14 Apr 2026 13:09:48 +0000
Subject: [PATCH] icons: resolve localized menu labels via img src
Menu titles in the app switcher dropdown and sidebar header are
translated (e.g. Azerbaijani), so looking up THEME_ICONS by textContent
missed everything. resolveEnglishKey() now extracts the untranslated
icon name from the
URL, falls back to scanning
frappe.boot.desktop_icons for a matching __(label), then the text.
Also adds a "taxes az" alias to THEME_ICONS.chrome so our new
Taxes Az desktop icon renders the tax document SVG instead of the
alphabet fallback.
Co-Authored-By: Claude Opus 4.6 (1M context)
---
jey_theme/public/js/jey_theme.js | 36 ++++++++++++++++++++++++--------
1 file changed, 27 insertions(+), 9 deletions(-)
diff --git a/jey_theme/public/js/jey_theme.js b/jey_theme/public/js/jey_theme.js
index dd3722c..331535d 100644
--- a/jey_theme/public/js/jey_theme.js
+++ b/jey_theme/public/js/jey_theme.js
@@ -103,6 +103,7 @@
payments: { paths: '' },
"financial reports": { paths: '' },
taxes: { paths: '' },
+ "taxes az": { paths: '' },
banking: { paths: '' },
budget: { paths: '' },
"share management": { paths: '' },
@@ -302,6 +303,30 @@
the current theme's SVG icons (same as desktop).
================================================================== */
+ /* Menu titles are localized (e.g. Azerbaijani "Mühasibat uçotu"), so the
+ lookup key is taken from the untranslated img src filename first, then
+ from a reverse-lookup over frappe.boot.desktop_icons by __(label), and
+ only last from the displayed text as a best-effort fallback. */
+ function resolveEnglishKey(item) {
+ var img = item.querySelector("img.logo[src]");
+ if (img) {
+ var m = img.getAttribute("src").match(/\/([^\/]+)\.svg(\?|$)/);
+ if (m) return m[1].replace(/_/g, " ").toLowerCase();
+ }
+ var titleEl = item.querySelector(".menu-item-title, .header-title");
+ if (!titleEl) return null;
+ var titleText = titleEl.textContent.trim();
+ if (window.frappe && frappe.boot && Array.isArray(frappe.boot.desktop_icons) && typeof __ === "function") {
+ for (var i = 0; i < frappe.boot.desktop_icons.length; i++) {
+ var dIcon = frappe.boot.desktop_icons[i];
+ if (dIcon && dIcon.label && __(dIcon.label) === titleText) {
+ return dIcon.label.toLowerCase();
+ }
+ }
+ }
+ return titleText.toLowerCase();
+ }
+
function processContextMenuIcons() {
document.querySelectorAll(".frappe-menu .dropdown-menu-item").forEach(function (item) {
var iconDiv = item.querySelector(".menu-item-icon");
@@ -310,11 +335,7 @@
// Skip chevron icons (the second .menu-item-icon with margin-left:auto)
if (iconDiv.style.marginLeft === "auto") return;
- var titleEl = item.querySelector(".menu-item-title");
- if (!titleEl) return;
-
- var key = titleEl.textContent.trim().toLowerCase();
- // Only replace if there's a real icon in THEME_ICONS (skip unknown items)
+ var key = resolveEnglishKey(item);
if (!hasIconDef(key)) return;
iconDiv.innerHTML = "";
@@ -333,10 +354,7 @@
var logo = header.querySelector(".header-logo");
if (!logo || logo.querySelector(".jey-icon")) return;
- var titleEl = header.querySelector(".header-title");
- if (!titleEl) return;
-
- var key = titleEl.textContent.trim().toLowerCase();
+ var key = resolveEnglishKey(header);
if (!hasIconDef(key)) return;
logo.innerHTML = "";