Merge origin/main (i18n) with cross-site location overview

Resolve conflicts between the i18n refactor and the new cross-site
location overview: new strings use gettext with German translations
(.po/.mo updated), version bumped to 0.18.0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
MrBlakeandClaude Opus 5.5 committed 2026-11-16 13:06:46 +01:00
commit d7c86289b1
37 files changed
+2108 -421

No files matched your search

+11 -7
View File
@@ -4,6 +4,9 @@ from collections import OrderedDict, defaultdict, deque
from dataclasses import dataclass, field
from io import BytesIO
from django.utils.translation import gettext as _
from django.utils.translation import ngettext
from .symbols import KINDS, SymbolResolver, builtin_icon
MAX_PER_ROW = 12 # breitere Zeilen werden umgebrochen
@@ -103,7 +106,7 @@ def build_graphs(scope, opts, per="site"):
def context(d):
"""Untertitel eines externen Geräts: wo es steht."""
if per == "rack":
return [f"Rack {d.rack}" if d.rack else str(d.site)]
return [_("Rack %(name)s") % {"name": d.rack} if d.rack else str(d.site)]
return [str(d.site)]
graphs = []
@@ -134,10 +137,10 @@ def build_graphs(scope, opts, per="site"):
if nodes:
_layout(nodes, edges)
if per == "site":
title = f"Standort {group}"
title = _("Site %(name)s") % {"name": group}
else:
where = " / ".join(str(x) for x in (group.site, group.location) if x)
title = f"Rack {group.name} ({where})"
title = _("Rack %(name)s (%(where)s)") % {"name": group.name, "where": where}
graphs.append(Graph(title, nodes, edges))
return graphs
@@ -296,8 +299,8 @@ def build_location_graphs(scope, opts, combined=False):
where.append(str(loc.parent))
sub = [" / ".join(where)] if where else []
n_racks, n_dev = len(racks[loc.pk]), count[loc.pk]
parts = [f"{n_racks} Rack" + ("s" if n_racks != 1 else "")] if n_racks else []
parts.append(f"{n_dev} Gerät" + ("e" if n_dev != 1 else ""))
parts = [ngettext("%(n)d rack", "%(n)d racks", n_racks) % {"n": n_racks}] if n_racks else []
parts.append(ngettext("%(n)d device", "%(n)d devices", n_dev) % {"n": n_dev})
sub.append(" · ".join(parts))
nodes[f"l{loc.pk}"] = Node(f"l{loc.pk}", loc.name, "location", builtin_icon("location"), sub, tier=tier[loc.pk])
members = set(nodes)
@@ -319,7 +322,8 @@ def build_location_graphs(scope, opts, combined=False):
nodes = OrderedDict((k, v) for k, v in nodes.items() if k in linked)
if nodes:
_layout(nodes, edges)
graphs.append(Graph("Alle Standorte" if combined else f"Standort {site}", nodes, edges))
title = _("All sites") if combined else _("Site %(name)s") % {"name": site}
graphs.append(Graph(title, nodes, edges))
return graphs
@@ -327,7 +331,7 @@ def _cable_summary(cables):
"""„2× SMF, 4× CAT6a“ – Kabel ohne Typ zählen als „Kabel“."""
types = defaultdict(int)
for c in cables:
types[c.get_type_display() if c.type else "Kabel"] += 1
types[c.get_type_display() if c.type else _("Cable")] += 1
return ", ".join(f"{n}× {t}" for t, n in sorted(types.items(), key=lambda x: -x[1]))