feat(gui): sidebar sections + non-technical tool labels
Sidebar nav now groups tools under Data Review / Data Cleaners / Transformations / Automations via st.navigation, replacing the flat auto-discovered list. Tool display names switch to action-first phrasing (Find Duplicates, Fix Missing Values, Find Unusual Values, Standardize Formats, Clean Text, Quality Check, Map Columns, Combine Files, Automated Workflows) in EN + ES packs and on each page's H1. The Data Cleaners section follows the requested order: Missing Values → Outliers → Text Cleaner → Format Standardizer → Deduplicator → Quality Check. (Text Cleaner kept inside cleaners since the request didn't list it but the tool still ships.) Registry now carries a section field; helpers added: tools_in_section(), section_label(). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
256
src/gui/app.py
256
src/gui/app.py
@@ -2,6 +2,14 @@
|
||||
|
||||
Launch:
|
||||
streamlit run src/gui/app.py
|
||||
|
||||
This module is the navigation manager for the full GUI: it registers
|
||||
every tool page with ``st.navigation`` so the sidebar can render
|
||||
section headers ("Data Review", "Data Cleaners", "Transformations",
|
||||
"Automations") instead of the flat numbered list Streamlit's
|
||||
auto-page-discovery would produce. The Home page itself is registered
|
||||
as a callable defined below so the entry script remains the single
|
||||
file users invoke.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -18,102 +26,186 @@ if str(_project_root) not in sys.path:
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Page config
|
||||
# Home page (rendered when the user selects the default nav entry)
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
from src.gui.components import (
|
||||
findings_count_for_tool,
|
||||
hide_streamlit_chrome,
|
||||
upload_and_analyze_section,
|
||||
)
|
||||
from src.i18n import t
|
||||
def _home_page() -> None:
|
||||
"""Render the home page — upload section + tool grid + footer."""
|
||||
from src.gui.components import (
|
||||
findings_count_for_tool,
|
||||
hide_streamlit_chrome,
|
||||
upload_and_analyze_section,
|
||||
)
|
||||
from src.gui.tools_registry import (
|
||||
TOOLS,
|
||||
section_label,
|
||||
tool_description,
|
||||
tool_name,
|
||||
)
|
||||
from src.i18n import t
|
||||
from src.license import get_manager
|
||||
|
||||
st.set_page_config(
|
||||
page_title=t("home.page_title"),
|
||||
page_icon="🧹",
|
||||
layout="wide",
|
||||
)
|
||||
st.set_page_config(
|
||||
page_title=t("home.page_title"),
|
||||
page_icon="🧹",
|
||||
layout="wide",
|
||||
)
|
||||
hide_streamlit_chrome()
|
||||
|
||||
# ``hide_streamlit_chrome`` also renders the sidebar language selector,
|
||||
# so every page that hides chrome picks up the same picker.
|
||||
hide_streamlit_chrome()
|
||||
st.title(t("home.title"))
|
||||
st.caption(t("home.caption"))
|
||||
|
||||
st.divider()
|
||||
|
||||
upload_and_analyze_section()
|
||||
|
||||
st.divider()
|
||||
|
||||
# Per-tier feature set for badging — Ready tools that the user's
|
||||
# tier doesn't unlock get a red "🔒 Locked" pill instead of the green
|
||||
# "Ready" so they see at a glance which tools an upgrade would
|
||||
# unlock. Dev-mode skips the lock check so the home grid renders the
|
||||
# full SKU during development.
|
||||
_license_state = get_manager().current_state()
|
||||
_unlocked_features = (
|
||||
set(_license_state.features) if _license_state.valid else set()
|
||||
)
|
||||
_dev_mode = get_manager().dev_mode
|
||||
|
||||
# Group tool cards by sidebar section so the home grid mirrors the
|
||||
# left-nav layout — same vocabulary, same ordering.
|
||||
sections: list[tuple[str, list]] = []
|
||||
for section in ("review", "cleaners", "transformations", "automations"):
|
||||
tools = [tool for tool in TOOLS if tool.section == section]
|
||||
if not tools:
|
||||
continue
|
||||
sections.append((section_label(section), tools))
|
||||
|
||||
for header, tools in sections:
|
||||
st.subheader(header)
|
||||
for row_start in range(0, len(tools), 3):
|
||||
cols = st.columns(3)
|
||||
for i, col in enumerate(cols):
|
||||
idx = row_start + i
|
||||
if idx >= len(tools):
|
||||
break
|
||||
tool = tools[idx]
|
||||
with col:
|
||||
tool_locked = (
|
||||
tool.status == "Ready"
|
||||
and not _dev_mode
|
||||
and tool.tool_id not in _unlocked_features
|
||||
)
|
||||
if tool_locked:
|
||||
status_key = "license.status_locked"
|
||||
status_color = "red"
|
||||
elif tool.status == "Ready":
|
||||
status_key = "status.ready"
|
||||
status_color = "green"
|
||||
else:
|
||||
status_key = "status.coming_soon"
|
||||
status_color = "orange"
|
||||
|
||||
badge = ""
|
||||
n = findings_count_for_tool(tool.tool_id)
|
||||
if n:
|
||||
badge_key = (
|
||||
"home.findings_badge_one"
|
||||
if n == 1
|
||||
else "home.findings_badge_other"
|
||||
)
|
||||
badge = f" :red-background[**{t(badge_key, n=n)}**]"
|
||||
lock_glyph = "🔒 " if tool_locked else ""
|
||||
st.markdown(
|
||||
f"### {tool.icon} {tool_name(tool.tool_id)}{badge}\n\n"
|
||||
f"{tool_description(tool.tool_id)}\n\n"
|
||||
f":{status_color}[**{lock_glyph}{t(status_key)}**]"
|
||||
)
|
||||
|
||||
st.divider()
|
||||
st.caption(t("chrome.footer"))
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Home page
|
||||
# Navigation registration
|
||||
# ---------------------------------------------------------------------------
|
||||
#
|
||||
# ``st.navigation`` overrides Streamlit's auto-discovery of the
|
||||
# ``pages/`` directory, so every page we want in the sidebar must be
|
||||
# listed here. The dict key becomes the section header rendered above
|
||||
# the entries; an empty-string key suppresses the header so the Home
|
||||
# entry sits at the top without a label above it.
|
||||
|
||||
st.title(t("home.title"))
|
||||
st.caption(t("home.caption"))
|
||||
from src.gui.tools_registry import TOOLS, section_label # noqa: E402
|
||||
from src.i18n import t as _t # noqa: E402
|
||||
|
||||
st.divider()
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Upload & analyze (optional onboarding step)
|
||||
# ---------------------------------------------------------------------------
|
||||
def _page_for(tool_id: str, *, page_slug: str, icon: str, title: str) -> "st.Page":
|
||||
return st.Page(
|
||||
f"pages/{page_slug}.py",
|
||||
title=title,
|
||||
icon=icon,
|
||||
url_path=tool_id,
|
||||
)
|
||||
|
||||
upload_and_analyze_section()
|
||||
|
||||
st.divider()
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Tool cards
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
from src.gui.tools_registry import TOOLS, tool_description, tool_name
|
||||
from src.license import get_manager
|
||||
|
||||
# Per-tier feature set for badging — Ready tools that the user's
|
||||
# tier doesn't unlock get a red "🔒 Locked" pill instead of the green
|
||||
# "Ready" so they see at a glance which tools an upgrade would
|
||||
# unlock. Dev-mode skips the lock check so the home grid renders the
|
||||
# full SKU during development.
|
||||
_license_state = get_manager().current_state()
|
||||
_unlocked_features = set(_license_state.features) if _license_state.valid else set()
|
||||
_dev_mode = get_manager().dev_mode
|
||||
|
||||
# Render tool cards in a 3-column grid. Cards picked up by the analyzer get a
|
||||
# coloured "N findings" badge so the user can see at a glance which tools
|
||||
# would help with the just-uploaded file.
|
||||
for row_start in range(0, len(TOOLS), 3):
|
||||
cols = st.columns(3)
|
||||
for i, col in enumerate(cols):
|
||||
idx = row_start + i
|
||||
if idx >= len(TOOLS):
|
||||
break
|
||||
tool = TOOLS[idx]
|
||||
with col:
|
||||
tool_locked = (
|
||||
tool.status == "Ready"
|
||||
and not _dev_mode
|
||||
and tool.tool_id not in _unlocked_features
|
||||
def _build_navigation() -> dict[str, list]:
|
||||
by_section: dict[str, list] = {
|
||||
"review": [],
|
||||
"cleaners": [],
|
||||
"transformations": [],
|
||||
"automations": [],
|
||||
}
|
||||
for tool in TOOLS:
|
||||
by_section[tool.section].append(
|
||||
_page_for(
|
||||
tool.tool_id,
|
||||
page_slug=tool.page_slug,
|
||||
icon=tool.icon,
|
||||
title=tool.name,
|
||||
)
|
||||
if tool_locked:
|
||||
status_key = "license.status_locked"
|
||||
status_color = "red"
|
||||
elif tool.status == "Ready":
|
||||
status_key = "status.ready"
|
||||
status_color = "green"
|
||||
else:
|
||||
status_key = "status.coming_soon"
|
||||
status_color = "orange"
|
||||
)
|
||||
|
||||
badge = ""
|
||||
n = findings_count_for_tool(tool.tool_id)
|
||||
if n:
|
||||
badge_key = "home.findings_badge_one" if n == 1 else "home.findings_badge_other"
|
||||
badge = f" :red-background[**{t(badge_key, n=n)}**]"
|
||||
lock_glyph = "🔒 " if tool_locked else ""
|
||||
st.markdown(
|
||||
f"### {tool.icon} {tool_name(tool.tool_id)}{badge}\n\n"
|
||||
f"{tool_description(tool.tool_id)}\n\n"
|
||||
f":{status_color}[**{lock_glyph}{t(status_key)}**]"
|
||||
)
|
||||
# The Review gate has no entry in the registry (it isn't a "tool")
|
||||
# so register it by hand at the top of its section.
|
||||
review_page = st.Page(
|
||||
"pages/0_Review.py",
|
||||
title=_t("nav.review_page_title") or "Review",
|
||||
icon="🛡️",
|
||||
url_path="review",
|
||||
)
|
||||
by_section["review"].insert(0, review_page)
|
||||
|
||||
home = st.Page(
|
||||
_home_page,
|
||||
title=_t("nav.home_page_title") or "Home",
|
||||
icon="🧹",
|
||||
default=True,
|
||||
url_path="home",
|
||||
)
|
||||
activate = st.Page(
|
||||
"pages/_Activate.py",
|
||||
title=_t("nav.activate_title") or "Activate",
|
||||
icon="🔑",
|
||||
url_path="activate",
|
||||
)
|
||||
close = st.Page(
|
||||
"pages/99_Close.py",
|
||||
title=_t("nav.close_title") or "Close",
|
||||
icon="🛑",
|
||||
url_path="close",
|
||||
)
|
||||
|
||||
account_header = _t("nav.section_account") or "Account"
|
||||
return {
|
||||
"": [home],
|
||||
section_label("review"): by_section["review"],
|
||||
section_label("cleaners"): by_section["cleaners"],
|
||||
section_label("transformations"): by_section["transformations"],
|
||||
section_label("automations"): by_section["automations"],
|
||||
account_header: [activate, close],
|
||||
}
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Footer
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
st.divider()
|
||||
st.caption(t("chrome.footer"))
|
||||
pg = st.navigation(_build_navigation())
|
||||
pg.run()
|
||||
|
||||
@@ -54,7 +54,7 @@ for key, default in _DEFAULTS.items():
|
||||
# Header
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
st.title("🔍 Deduplicator")
|
||||
st.title("🔍 Find Duplicates")
|
||||
st.caption("Find and remove duplicate rows in CSV, delimited text, and Excel files.")
|
||||
|
||||
|
||||
@@ -363,5 +363,5 @@ else:
|
||||
st.divider()
|
||||
st.caption(
|
||||
"Runs locally. Your data never leaves this computer. "
|
||||
"| DataTools Deduplicator v3.0"
|
||||
"| DataTools v3.0"
|
||||
)
|
||||
|
||||
@@ -39,7 +39,7 @@ require_normalization_gate()
|
||||
# Header
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
st.title("✂️ Text Cleaner")
|
||||
st.title("✂️ Clean Text")
|
||||
st.caption(
|
||||
"Trim whitespace, fold smart quotes, strip invisible characters, and "
|
||||
"normalize line endings. Runs locally — your data never leaves this computer."
|
||||
|
||||
@@ -37,7 +37,7 @@ require_normalization_gate()
|
||||
# Header
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
st.title("📐 Format Standardizer")
|
||||
st.title("📐 Standardize Formats")
|
||||
st.caption(
|
||||
"Canonicalize dates, phone numbers, currency, names, addresses, and "
|
||||
"booleans on a per-column basis. Runs locally — your data never leaves "
|
||||
|
||||
@@ -38,7 +38,7 @@ require_normalization_gate()
|
||||
# Header
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
st.title("🕳️ Missing Value Handler")
|
||||
st.title("🕳️ Fix Missing Values")
|
||||
st.caption(
|
||||
"Detect disguised nulls, profile missingness, and apply imputation or "
|
||||
"drop strategies. Runs locally — your data never leaves this computer."
|
||||
|
||||
@@ -39,7 +39,7 @@ require_normalization_gate()
|
||||
# Header
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
st.title("🗂️ Column Mapper")
|
||||
st.title("🗂️ Map Columns")
|
||||
st.caption(
|
||||
"Rename columns, enforce a target schema, and coerce types. Runs locally — "
|
||||
"your data never leaves this computer."
|
||||
|
||||
@@ -26,7 +26,7 @@ require_normalization_gate()
|
||||
# Header
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
st.title("📊 Outlier Detector")
|
||||
st.title("📊 Find Unusual Values")
|
||||
st.caption("Detect and handle outliers in numeric columns.")
|
||||
|
||||
st.info("This tool is under development.")
|
||||
|
||||
@@ -26,7 +26,7 @@ require_normalization_gate()
|
||||
# Header
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
st.title("📎 Multi-File Merger")
|
||||
st.title("📎 Combine Files")
|
||||
st.caption("Combine multiple CSV and Excel files into one dataset.")
|
||||
|
||||
st.info("This tool is under development.")
|
||||
|
||||
@@ -26,7 +26,7 @@ require_normalization_gate()
|
||||
# Header
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
st.title("✅ Validator & Reporter")
|
||||
st.title("✅ Quality Check")
|
||||
st.caption("Validate data against rules and generate quality reports.")
|
||||
|
||||
st.info("This tool is under development.")
|
||||
|
||||
@@ -40,7 +40,7 @@ require_normalization_gate()
|
||||
# Header
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
st.title("⚙️ Pipeline Runner")
|
||||
st.title("⚙️ Automated Workflows")
|
||||
st.caption(
|
||||
"Chain DataTools cleaning steps into one repeatable workflow. The "
|
||||
"pipeline recommends an order; you stay in control."
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
"""Per-tool manifest registry.
|
||||
|
||||
Single source of truth for what tools exist, their display strings, and
|
||||
the tier (which controls whether a tool ships in a given build SKU). The
|
||||
home-page sidebar consumes this list; future per-tool packaging will
|
||||
filter it via the ``tier`` field.
|
||||
Single source of truth for what tools exist, their display strings, the
|
||||
left-nav section they belong to, and the tier (which controls whether a
|
||||
tool ships in a given build SKU). The home-page sidebar consumes this
|
||||
list; future per-tool packaging will filter it via the ``tier`` field.
|
||||
|
||||
Adding a tool: append one ``Tool`` entry. Page filenames must match the
|
||||
``page_slug`` so Streamlit's automatic page discovery picks them up.
|
||||
@@ -22,6 +22,10 @@ from typing import Literal
|
||||
|
||||
Tier = Literal["core", "pro", "enterprise"]
|
||||
Status = Literal["Ready", "Coming Soon"]
|
||||
# Sidebar grouping. The Review gate is its own section; cleaners,
|
||||
# transformations, and automations group the tools by what the user is
|
||||
# trying to accomplish rather than by implementation detail.
|
||||
Section = Literal["review", "cleaners", "transformations", "automations"]
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@@ -34,102 +38,127 @@ class Tool:
|
||||
description: str # One-sentence card body.
|
||||
page_slug: str # Streamlit page filename without ".py" (e.g. "1_Deduplicator").
|
||||
status: Status # "Ready" or "Coming Soon" — drives the card badge color.
|
||||
section: Section # Sidebar group this tool belongs to.
|
||||
tier: Tier = "core" # Build-time gating hook; every tool is "core" today.
|
||||
|
||||
|
||||
# Order in this list IS the order shown in each sidebar section, so
|
||||
# arranging it carefully matters: within "cleaners" we lead with the
|
||||
# operations a non-technical user is most likely to need (filling
|
||||
# blanks, flagging outliers) before progressing to format cleanup,
|
||||
# dedup, and the final quality report.
|
||||
TOOLS: list[Tool] = [
|
||||
Tool(
|
||||
tool_id="01_deduplicator",
|
||||
icon="🔍",
|
||||
name="Deduplicator",
|
||||
description=(
|
||||
"Fuzzy matching, normalization, survivor selection, and "
|
||||
"interactive review."
|
||||
),
|
||||
page_slug="1_Deduplicator",
|
||||
status="Ready",
|
||||
),
|
||||
Tool(
|
||||
tool_id="02_text_cleaner",
|
||||
icon="✂️",
|
||||
name="Text Cleaner",
|
||||
description=(
|
||||
"Whitespace trim, multi-space collapse, Unicode normalization, "
|
||||
"BOM and line-ending handling."
|
||||
),
|
||||
page_slug="2_Text_Cleaner",
|
||||
status="Ready",
|
||||
),
|
||||
Tool(
|
||||
tool_id="03_format_standardizer",
|
||||
icon="📐",
|
||||
name="Format Standardizer",
|
||||
description=(
|
||||
"Standardize dates, currencies, names, phone numbers, and addresses."
|
||||
),
|
||||
page_slug="3_Format_Standardizer",
|
||||
status="Ready",
|
||||
),
|
||||
Tool(
|
||||
tool_id="04_missing_handler",
|
||||
icon="🕳️",
|
||||
name="Missing Value Handler",
|
||||
name="Fix Missing Values",
|
||||
description=(
|
||||
"Detect disguised nulls, missingness analysis, and imputation strategies."
|
||||
),
|
||||
page_slug="4_Missing_Values",
|
||||
status="Ready",
|
||||
),
|
||||
Tool(
|
||||
tool_id="05_column_mapper",
|
||||
icon="🗂️",
|
||||
name="Column Mapper",
|
||||
description="Rename columns, enforce a target schema, and coerce types.",
|
||||
page_slug="5_Column_Mapper",
|
||||
status="Ready",
|
||||
section="cleaners",
|
||||
),
|
||||
Tool(
|
||||
tool_id="06_outlier_detector",
|
||||
icon="📊",
|
||||
name="Outlier Detector",
|
||||
name="Find Unusual Values",
|
||||
description=(
|
||||
"Z-score, IQR, and MAD detection with domain-rule violations and "
|
||||
"winsorization."
|
||||
),
|
||||
page_slug="6_Outlier_Detector",
|
||||
status="Coming Soon",
|
||||
section="cleaners",
|
||||
),
|
||||
Tool(
|
||||
tool_id="07_multi_file_merger",
|
||||
icon="📎",
|
||||
name="Multi-File Merger",
|
||||
description="Combine multiple CSV/Excel files with schema alignment.",
|
||||
page_slug="7_Multi_File_Merger",
|
||||
status="Coming Soon",
|
||||
tool_id="02_text_cleaner",
|
||||
icon="✂️",
|
||||
name="Clean Text",
|
||||
description=(
|
||||
"Whitespace trim, multi-space collapse, Unicode normalization, "
|
||||
"BOM and line-ending handling."
|
||||
),
|
||||
page_slug="2_Text_Cleaner",
|
||||
status="Ready",
|
||||
section="cleaners",
|
||||
),
|
||||
Tool(
|
||||
tool_id="03_format_standardizer",
|
||||
icon="📐",
|
||||
name="Standardize Formats",
|
||||
description=(
|
||||
"Standardize dates, currencies, names, phone numbers, and addresses."
|
||||
),
|
||||
page_slug="3_Format_Standardizer",
|
||||
status="Ready",
|
||||
section="cleaners",
|
||||
),
|
||||
Tool(
|
||||
tool_id="01_deduplicator",
|
||||
icon="🔍",
|
||||
name="Find Duplicates",
|
||||
description=(
|
||||
"Fuzzy matching, normalization, survivor selection, and "
|
||||
"interactive review."
|
||||
),
|
||||
page_slug="1_Deduplicator",
|
||||
status="Ready",
|
||||
section="cleaners",
|
||||
),
|
||||
Tool(
|
||||
tool_id="08_validator_reporter",
|
||||
icon="✅",
|
||||
name="Validator & Reporter",
|
||||
name="Quality Check",
|
||||
description=(
|
||||
"Validate against rules and generate PDF/Excel quality reports."
|
||||
),
|
||||
page_slug="8_Validator_Reporter",
|
||||
status="Coming Soon",
|
||||
section="cleaners",
|
||||
),
|
||||
Tool(
|
||||
tool_id="05_column_mapper",
|
||||
icon="🗂️",
|
||||
name="Map Columns",
|
||||
description="Rename columns, enforce a target schema, and coerce types.",
|
||||
page_slug="5_Column_Mapper",
|
||||
status="Ready",
|
||||
section="transformations",
|
||||
),
|
||||
Tool(
|
||||
tool_id="07_multi_file_merger",
|
||||
icon="📎",
|
||||
name="Combine Files",
|
||||
description="Combine multiple CSV/Excel files with schema alignment.",
|
||||
page_slug="7_Multi_File_Merger",
|
||||
status="Coming Soon",
|
||||
section="transformations",
|
||||
),
|
||||
Tool(
|
||||
tool_id="09_pipeline_runner",
|
||||
icon="⚙️",
|
||||
name="Pipeline Runner",
|
||||
name="Automated Workflows",
|
||||
description=(
|
||||
"Chain tools in recommended order and pass output between steps."
|
||||
),
|
||||
page_slug="9_Pipeline_Runner",
|
||||
status="Ready",
|
||||
section="automations",
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
# Display labels for each sidebar section. Kept here so i18n falls back
|
||||
# to a sensible English string if a translation pack is missing the key.
|
||||
SECTION_LABELS: dict[Section, str] = {
|
||||
"review": "Data Review",
|
||||
"cleaners": "Data Cleaners",
|
||||
"transformations": "Transformations",
|
||||
"automations": "Automations",
|
||||
}
|
||||
|
||||
|
||||
def tools_for_tier(*tiers: Tier) -> list[Tool]:
|
||||
"""Subset filter for build-time slicing.
|
||||
|
||||
@@ -142,6 +171,11 @@ def tools_for_tier(*tiers: Tier) -> list[Tool]:
|
||||
return [t for t in TOOLS if t.tier in keep]
|
||||
|
||||
|
||||
def tools_in_section(section: Section) -> list[Tool]:
|
||||
"""Return the tools in *section*, preserving registry order."""
|
||||
return [t for t in TOOLS if t.section == section]
|
||||
|
||||
|
||||
def tool_by_id(tool_id: str) -> Tool | None:
|
||||
return next((t for t in TOOLS if t.tool_id == tool_id), None)
|
||||
|
||||
@@ -167,3 +201,12 @@ def tool_description(tool_id: str) -> str:
|
||||
fallback = tool.description if tool else ""
|
||||
translated = _t(f"tools.{tool_id}.description")
|
||||
return translated if translated != f"tools.{tool_id}.description" else fallback
|
||||
|
||||
|
||||
def section_label(section: Section) -> str:
|
||||
"""Return the localized sidebar section header."""
|
||||
from src.i18n import t as _t
|
||||
fallback = SECTION_LABELS[section]
|
||||
key = f"nav.section_{section}"
|
||||
translated = _t(key)
|
||||
return translated if translated != key else fallback
|
||||
|
||||
Reference in New Issue
Block a user