feat(i18n): English source strings with German translation
All UI texts and generated document texts use gettext; exports follow the user's language. Adds a check that README and PluginConfig version ranges match. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
0d046f3a9d
commit
9dba7e07a0
35 files changed
+1841
-364
No files matched your search
@@ -1,4 +1,5 @@
|
||||
from django import forms
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from dcim.models import DeviceRole, DeviceType, Location, Site
|
||||
from netbox.plugins import get_plugin_config
|
||||
from tenancy.models import Tenant, TenantGroup
|
||||
@@ -9,93 +10,93 @@ from .models import BrandingProfile, TopologySymbol
|
||||
from .sections import DEFAULT_DEVICE_COLUMNS, DEVICE_COLUMNS, SECTIONS
|
||||
from .symbols import KIND_CHOICES
|
||||
|
||||
FORMAT_CHOICES = (("pdf", "PDF"), ("docx", "Word"), ("html", "HTML-Vorschau"))
|
||||
FORMAT_CHOICES = (("pdf", "PDF"), ("docx", "Word"), ("html", _("HTML preview")))
|
||||
|
||||
|
||||
class ScopeSelectForm(forms.Form):
|
||||
site = DynamicModelChoiceField(queryset=Site.objects.all(), required=False, label="Standort")
|
||||
location = DynamicModelChoiceField(queryset=Location.objects.all(), required=False, label="Lokation")
|
||||
tenant = DynamicModelChoiceField(queryset=Tenant.objects.all(), required=False, label="Mandant")
|
||||
tenantgroup = DynamicModelChoiceField(queryset=TenantGroup.objects.all(), required=False, label="Mandantengruppe")
|
||||
site = DynamicModelChoiceField(queryset=Site.objects.all(), required=False, label=_("Site"))
|
||||
location = DynamicModelChoiceField(queryset=Location.objects.all(), required=False, label=_("Location"))
|
||||
tenant = DynamicModelChoiceField(queryset=Tenant.objects.all(), required=False, label=_("Tenant"))
|
||||
tenantgroup = DynamicModelChoiceField(queryset=TenantGroup.objects.all(), required=False, label=_("Tenant group"))
|
||||
|
||||
def clean(self):
|
||||
data = super().clean()
|
||||
chosen = [(k, v) for k, v in data.items() if v]
|
||||
if len(chosen) != 1:
|
||||
raise forms.ValidationError("Bitte genau einen Scope auswählen.")
|
||||
raise forms.ValidationError(_("Select exactly one scope."))
|
||||
data["kind"], data["obj"] = chosen[0]
|
||||
return data
|
||||
|
||||
|
||||
class ExportForm(forms.Form):
|
||||
format = forms.ChoiceField(choices=FORMAT_CHOICES, initial="pdf", label="Format")
|
||||
title = forms.CharField(max_length=200, label="Titel")
|
||||
subtitle = forms.CharField(max_length=200, required=False, label="Untertitel")
|
||||
author = forms.CharField(max_length=100, required=False, label="Erstellt von")
|
||||
branding = forms.ChoiceField(choices=(), label="Design / Firma")
|
||||
format = forms.ChoiceField(choices=FORMAT_CHOICES, initial="pdf", label=_("Format"))
|
||||
title = forms.CharField(max_length=200, label=_("Title"))
|
||||
subtitle = forms.CharField(max_length=200, required=False, label=_("Subtitle"))
|
||||
author = forms.CharField(max_length=100, required=False, label=_("Created by"))
|
||||
branding = forms.ChoiceField(choices=(), label=_("Design / company"))
|
||||
|
||||
sections = forms.MultipleChoiceField(
|
||||
choices=[(s.key, s.label) for s in SECTIONS.values()],
|
||||
initial=[s.key for s in SECTIONS.values() if s.default],
|
||||
widget=forms.CheckboxSelectMultiple,
|
||||
label="Inhalte",
|
||||
label=_("Contents"),
|
||||
)
|
||||
|
||||
roles = forms.ModelMultipleChoiceField(
|
||||
queryset=DeviceRole.objects.none(), required=False, widget=forms.CheckboxSelectMultiple, label="Geräterollen"
|
||||
queryset=DeviceRole.objects.none(), required=False, widget=forms.CheckboxSelectMultiple, label=_("Device roles")
|
||||
)
|
||||
device_columns = forms.MultipleChoiceField(
|
||||
choices=[(k, v[0]) for k, v in DEVICE_COLUMNS.items()],
|
||||
initial=DEFAULT_DEVICE_COLUMNS,
|
||||
required=False,
|
||||
widget=forms.CheckboxSelectMultiple,
|
||||
label="Gerätespalten",
|
||||
label=_("Device columns"),
|
||||
)
|
||||
group_by_site = forms.BooleanField(required=False, initial=True, label="Geräte nach Standort gruppieren")
|
||||
group_by_site = forms.BooleanField(required=False, initial=True, label=_("Group devices by site"))
|
||||
|
||||
disk_install_date = forms.BooleanField(required=False, initial=False, label="Einbaudatum der Datenträger anzeigen")
|
||||
disk_install_date = forms.BooleanField(required=False, initial=False, label=_("Show disk installation date"))
|
||||
|
||||
rack_svg = forms.BooleanField(required=False, initial=True, label="Rack-Ansichten (SVG) einbetten")
|
||||
rack_images = forms.BooleanField(required=False, initial=False, label="Gerätebilder anzeigen (wie in NetBox)")
|
||||
rack_svg = forms.BooleanField(required=False, initial=True, label=_("Embed rack elevations (SVG)"))
|
||||
rack_images = forms.BooleanField(required=False, initial=False, label=_("Show device images (as in NetBox)"))
|
||||
rack_faces = forms.MultipleChoiceField(
|
||||
choices=(("front", "Vorderseite"), ("rear", "Rückseite")),
|
||||
choices=(("front", _("Front")), ("rear", _("Rear"))),
|
||||
initial=["front"],
|
||||
required=False,
|
||||
widget=forms.CheckboxSelectMultiple,
|
||||
label="Rack-Seiten",
|
||||
label=_("Rack faces"),
|
||||
)
|
||||
rack_devices = forms.BooleanField(required=False, initial=True, label="Geräteliste je Rack")
|
||||
rack_pagebreak = forms.BooleanField(required=False, initial=True, label="Seitenumbruch nach jedem Rack")
|
||||
rack_devices = forms.BooleanField(required=False, initial=True, label=_("Device list per rack"))
|
||||
rack_pagebreak = forms.BooleanField(required=False, initial=True, label=_("Page break after each rack"))
|
||||
|
||||
topo_details = forms.MultipleChoiceField(
|
||||
choices=(("model", "Modell"), ("primary_ip", "Management-IP"), ("ports", "Ports an Verbindungen")),
|
||||
choices=(("model", _("Model")), ("primary_ip", _("Management IP")), ("ports", _("Ports on links"))),
|
||||
initial=["primary_ip"],
|
||||
required=False,
|
||||
widget=forms.CheckboxSelectMultiple,
|
||||
label="Beschriftung",
|
||||
label=_("Labels"),
|
||||
)
|
||||
topo_scope = forms.MultipleChoiceField(
|
||||
choices=(("site", "Gesamtes Netzwerk (je Standort)"), ("rack", "Je Rack")),
|
||||
choices=(("site", _("Whole network (per site)")), ("rack", _("Per rack"))),
|
||||
initial=["site"],
|
||||
required=False,
|
||||
widget=forms.CheckboxSelectMultiple,
|
||||
label="Umfang",
|
||||
label=_("Scope"),
|
||||
)
|
||||
topo_external = forms.BooleanField(
|
||||
required=False, initial=True, label="Provider-Leitungen & Geräte außerhalb anzeigen"
|
||||
required=False, initial=True, label=_("Show provider circuits and devices outside the scope")
|
||||
)
|
||||
topo_isolated = forms.BooleanField(required=False, initial=False, label="Unverkabelte Geräte anzeigen")
|
||||
topo_isolated = forms.BooleanField(required=False, initial=False, label=_("Show uncabled devices"))
|
||||
|
||||
ip_versions = forms.MultipleChoiceField(
|
||||
choices=(("4", "IPv4"), ("6", "IPv6")),
|
||||
initial=["4", "6"],
|
||||
required=False,
|
||||
widget=forms.CheckboxSelectMultiple,
|
||||
label="IP-Versionen",
|
||||
label=_("IP versions"),
|
||||
)
|
||||
|
||||
include_empty = forms.BooleanField(required=False, label="Leere Abschnitte trotzdem aufführen")
|
||||
include_secrets = forms.BooleanField(required=False, label="Geheimnisse (z.B. WLAN-PSK) mit exportieren")
|
||||
include_empty = forms.BooleanField(required=False, label=_("List empty sections anyway"))
|
||||
include_secrets = forms.BooleanField(required=False, label=_("Include secrets (e.g. Wi-Fi PSK)"))
|
||||
|
||||
def __init__(self, *args, scope=None, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
@@ -113,7 +114,7 @@ class ExportForm(forms.Form):
|
||||
roles = DeviceRole.objects.filter(pk__in=role_ids).order_by("name")
|
||||
self.fields["roles"].queryset = roles
|
||||
self.fields["roles"].initial = [r.pk for r in roles]
|
||||
self.fields["title"].initial = f"Netzwerkdokumentation {scope.obj}"
|
||||
self.fields["title"].initial = _("Network documentation %(name)s") % {"name": scope.obj}
|
||||
self.fields["subtitle"].initial = f"{scope.label}: {scope.obj}"
|
||||
if not get_plugin_config("netbox_customer_export", "allow_secrets"):
|
||||
del self.fields["include_secrets"]
|
||||
@@ -144,10 +145,10 @@ class BrandingProfileForm(forms.ModelForm):
|
||||
"extra_css": forms.Textarea(attrs={"rows": 4, "class": "form-control font-monospace"}),
|
||||
}
|
||||
help_texts = {
|
||||
"is_default": "Wird im Exportformular vorausgewählt.",
|
||||
"logo": "PNG oder JPG, erscheint auf dem Deckblatt.",
|
||||
"docx_template": ".docx oder .dotx: Formatvorlagen, Kopf-/Fußzeile und Ränder werden übernommen.",
|
||||
"docx_table_style": "Name wie in Word angezeigt, z.B. Gitternetztabelle 4 – Akzent 1. Leer = eigene Einfärbung.",
|
||||
"is_default": _("Preselected in the export form."),
|
||||
"logo": _("PNG or JPG, shown on the cover page."),
|
||||
"docx_template": _(".docx or .dotx: styles, header/footer and margins are applied."),
|
||||
"docx_table_style": _("Name as shown in Word, e.g. Grid Table 4 – Accent 1. Empty = own colouring."),
|
||||
}
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
@@ -161,17 +162,17 @@ class BrandingProfileForm(forms.ModelForm):
|
||||
|
||||
|
||||
class TopologySymbolForm(forms.ModelForm):
|
||||
device_type = DynamicModelChoiceField(queryset=DeviceType.objects.all(), required=False, label="Gerätetyp")
|
||||
role = DynamicModelChoiceField(queryset=DeviceRole.objects.all(), required=False, label="Geräterolle")
|
||||
device_type = DynamicModelChoiceField(queryset=DeviceType.objects.all(), required=False, label=_("Device type"))
|
||||
role = DynamicModelChoiceField(queryset=DeviceRole.objects.all(), required=False, label=_("Device role"))
|
||||
kind = forms.ChoiceField(
|
||||
choices=[("", "Automatisch")] + KIND_CHOICES, required=False, widget=forms.RadioSelect, label="Symbol"
|
||||
choices=[("", _("Automatic"))] + KIND_CHOICES, required=False, widget=forms.RadioSelect, label=_("Symbol")
|
||||
)
|
||||
|
||||
class Meta:
|
||||
model = TopologySymbol
|
||||
fields = ("device_type", "role", "kind", "icon")
|
||||
help_texts = {
|
||||
"icon": "PNG, JPG oder GIF, am besten quadratisch mit transparentem Hintergrund. Ersetzt das gewählte Symbol.",
|
||||
"icon": _("PNG, JPG or GIF, ideally square with a transparent background. Replaces the selected symbol."),
|
||||
}
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
||||
Reference in new issue
Block a user