feat(i18n): translate UI and import messages to English with German catalogue
English is now the source language for the dashboard, forms, menu, JavaScript progress texts and all import/export messages; a complete German catalogue ships as package data. Tenant-error detection also accepts the error code and the active-language message of netbox_utilities, and no longer imports netbox_utilities when it is installed but not enabled. A test keeps the README NetBox range in sync with min_version/max_version. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
409b239fca
commit
72e04fe086
21 files changed
+713
-156
No files matched your search
@@ -34,13 +34,13 @@ def test_archive_round_trip():
|
||||
|
||||
assert parsed.records == records()
|
||||
assert parsed.assets == {"assets/a.txt": b"data"}
|
||||
assert parsed.warnings == ["Das Archiv ist nicht signiert."]
|
||||
assert parsed.warnings == ["The archive is not signed."]
|
||||
|
||||
|
||||
def test_signed_archive_requires_matching_key():
|
||||
payload = build_archive(manifest(), records(), {}, signing_key="secret-a")
|
||||
|
||||
with pytest.raises(ArchiveValidationError, match="Archivsignatur"):
|
||||
with pytest.raises(ArchiveValidationError, match="archive signature"):
|
||||
read_archive(payload, max_size=1024 * 1024, max_objects=10, signing_key="secret-b")
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ def test_signed_archive_without_local_key_is_not_claimed_as_verified():
|
||||
|
||||
parsed = read_archive(payload, max_size=1024 * 1024, max_objects=10)
|
||||
|
||||
assert parsed.warnings == ["Das Archiv ist signiert, aber ohne konfigurierten Schlüssel nicht verifiziert."]
|
||||
assert parsed.warnings == ["The archive is signed but was not verified because no key is configured."]
|
||||
|
||||
|
||||
def test_modified_object_stream_is_rejected():
|
||||
@@ -63,7 +63,7 @@ def test_modified_object_stream_is_rejected():
|
||||
content = content.replace(b"Berlin", b"Hamburg")
|
||||
target.writestr(info, content)
|
||||
|
||||
with pytest.raises(ArchiveValidationError, match="Prüfsumme"):
|
||||
with pytest.raises(ArchiveValidationError, match="checksum"):
|
||||
read_archive(output.getvalue(), max_size=1024 * 1024, max_objects=10)
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ def test_modified_asset_is_rejected():
|
||||
content = b"modified"
|
||||
target.writestr(info, content)
|
||||
|
||||
with pytest.raises(ArchiveValidationError, match="Prüfsumme der Datei"):
|
||||
with pytest.raises(ArchiveValidationError, match="checksum of file"):
|
||||
read_archive(output.getvalue(), max_size=1024 * 1024, max_objects=10)
|
||||
|
||||
|
||||
@@ -88,12 +88,12 @@ def test_path_traversal_is_rejected():
|
||||
with zipfile.ZipFile(output, "w") as archive:
|
||||
archive.writestr("../manifest.json", json.dumps(manifest()))
|
||||
|
||||
with pytest.raises(ArchiveValidationError, match="Dateipfad"):
|
||||
with pytest.raises(ArchiveValidationError, match="file path"):
|
||||
read_archive(output.getvalue(), max_size=1024 * 1024, max_objects=10)
|
||||
|
||||
|
||||
def test_object_limit_is_enforced():
|
||||
payload = build_archive(manifest(), records() * 2, {})
|
||||
|
||||
with pytest.raises(ArchiveValidationError, match="zu viele Objekte"):
|
||||
with pytest.raises(ArchiveValidationError, match="too many objects"):
|
||||
read_archive(payload, max_size=1024 * 1024, max_objects=1)
|
||||
@@ -49,7 +49,7 @@ def test_port_mapping_conflicts_are_replaced_before_save():
|
||||
|
||||
assert deleted == [12]
|
||||
resolver.warn.assert_called_once()
|
||||
assert "Front-/Rear-Port-Verkabelung" in resolver.warn.call_args.args[1]
|
||||
assert "front/rear port cabling" in resolver.warn.call_args.args[1]
|
||||
|
||||
|
||||
def test_imported_cable_terminations_trigger_netbox_path_rebuild(monkeypatch):
|
||||
|
||||
@@ -140,7 +140,7 @@ def test_update_releases_exact_rack_occupant_and_places_imported_device(placemen
|
||||
assert (occupant.rack, occupant.position, occupant.face) == (rack, None, None)
|
||||
assert (imported.rack, imported.position, imported.face) == (rack, Decimal("31.0"), "front")
|
||||
assert len(warnings) == 1
|
||||
assert f"Zielgerät(e) {occupant.pk} (Existing)" in warnings[0]
|
||||
assert f"target device(s) {occupant.pk} (Existing)" in warnings[0]
|
||||
|
||||
|
||||
def test_skip_keeps_occupant_and_leaves_imported_device_unpositioned(placement_schema):
|
||||
@@ -165,7 +165,7 @@ def test_skip_keeps_occupant_and_leaves_imported_device_unpositioned(placement_s
|
||||
assert (occupant.rack, occupant.position, occupant.face) == (rack, Decimal("31.0"), "front")
|
||||
assert (imported.rack, imported.position, imported.face) == (rack, None, None)
|
||||
assert len(warnings) == 1
|
||||
assert "wurde ohne Position im Rack gespeichert" in warnings[0]
|
||||
assert "was saved without a rack position" in warnings[0]
|
||||
|
||||
|
||||
def test_fail_reports_rack_conflict_before_database_constraint(placement_schema):
|
||||
@@ -177,7 +177,7 @@ def test_fail_reports_rack_conflict_before_database_constraint(placement_schema)
|
||||
imported = PlacementDevice.objects.create(name="Imported", device_type=device_type)
|
||||
record_id, resolved, _, resolver, compatibility, placement = placement_context(imported, rack)
|
||||
|
||||
with pytest.raises(ImportConflictError, match="Rackplatzkonflikt.*Rack R01"):
|
||||
with pytest.raises(ImportConflictError, match="Rack position conflict.*Rack R01"):
|
||||
_apply_device_placements(
|
||||
[(record_id, placement)],
|
||||
resolved,
|
||||
|
||||
@@ -98,8 +98,8 @@ def test_oversized_image_is_resized_after_pillow_bomb_error(monkeypatch):
|
||||
assert stored_image.format == "PNG"
|
||||
assert import_warnings == [
|
||||
(
|
||||
f"Bild für extras.imageattachment:17 wurde von 11×10 auf "
|
||||
f"{obj.image_width}×{obj.image_height} Pixel verkleinert."
|
||||
f"Image for extras.imageattachment:17 was downscaled from 11×10 to "
|
||||
f"{obj.image_width}×{obj.image_height} pixels."
|
||||
)
|
||||
]
|
||||
assert Image.MAX_IMAGE_PIXELS == 50
|
||||
|
||||
@@ -246,8 +246,8 @@ def test_existing_unique_relation_is_released_before_reassignment():
|
||||
assert imported_owner.primary_ip6 == address
|
||||
assert warnings == [
|
||||
(
|
||||
"Eindeutige Referenz compat_tests.uniqueaddressowner.primary_ip6 wurde von "
|
||||
f"Zielobjekt(en) {previous_owner.pk} gelöst und dem importierten Objekt neu zugeordnet."
|
||||
"Unique reference compat_tests.uniqueaddressowner.primary_ip6 was released from target "
|
||||
f"object(s) {previous_owner.pk} and reassigned to the imported object."
|
||||
)
|
||||
]
|
||||
finally:
|
||||
@@ -288,9 +288,9 @@ def test_natural_key_rebinds_stale_mapping_instead_of_creating_duplicate(monkeyp
|
||||
assert existing == natural
|
||||
assert warnings == [
|
||||
(
|
||||
"Gespeicherte Zuordnung für dcim.rearport:77 wurde von Ziel-ID 999 auf "
|
||||
f"Ziel-ID {natural.pk} korrigiert, da der Fachschlüssel "
|
||||
f"{{'device': <Device: Device object ({device.pk})>, 'name': '3-LC'}} bereits existiert."
|
||||
"Stored mapping for dcim.rearport:77 was corrected from target ID 999 to "
|
||||
f"target ID {natural.pk} because the natural key "
|
||||
f"{{'device': <Device: Device object ({device.pk})>, 'name': '3-LC'}} already exists."
|
||||
)
|
||||
]
|
||||
finally:
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
import ast
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).parents[1]
|
||||
|
||||
|
||||
def _plugin_versions():
|
||||
tree = ast.parse((ROOT / "netbox_export" / "__init__.py").read_text(encoding="utf-8"))
|
||||
values = {
|
||||
target.id: node.value.value
|
||||
for node in ast.walk(tree)
|
||||
if isinstance(node, ast.Assign) and isinstance(node.value, ast.Constant)
|
||||
for target in node.targets
|
||||
if isinstance(target, ast.Name)
|
||||
}
|
||||
return values["min_version"], values["max_version"]
|
||||
|
||||
|
||||
def test_readme_netbox_range_matches_plugin_config():
|
||||
min_version, max_version = _plugin_versions()
|
||||
major, minor, patch = max_version.split(".")
|
||||
upper = f"{major}.{minor}.x" if patch == "99" else max_version # 4.7.99 is documented as 4.7.x
|
||||
expected = f"`{min_version}` – `{upper}`"
|
||||
readme = (ROOT / "README.md").read_text(encoding="utf-8")
|
||||
|
||||
assert f"| **NetBox** | {expected} |" in readme
|
||||
assert f"- NetBox {expected}" in readme
|
||||
|
||||
|
||||
def test_german_catalog_is_complete():
|
||||
po = ROOT / "netbox_export" / "locale" / "de" / "LC_MESSAGES" / "django.po"
|
||||
content = po.read_text(encoding="utf-8")
|
||||
entries = re.findall(r'^msgid ((?:".*"\n)+)msgstr ((?:".*"\n?)+)', content, re.MULTILINE)
|
||||
|
||||
assert "#, fuzzy" not in content
|
||||
assert [msgid for msgid, msgstr in entries[1:] if msgstr.strip() == '""'] == []
|
||||
assert po.with_suffix(".mo").is_file()
|
||||
@@ -171,8 +171,8 @@ def test_creates_and_assigns_auto_import_tenant_when_policy_is_active():
|
||||
assert len(manager.created) == 1
|
||||
assert warnings == [
|
||||
(
|
||||
'Der Mandant "Auto-Import" wurde automatisch erstellt und Objekten ohne '
|
||||
'auflösbaren Mandanten zugewiesen.'
|
||||
'The tenant "Auto-Import" was created automatically and assigned to objects without a '
|
||||
'resolvable tenant.'
|
||||
)
|
||||
]
|
||||
|
||||
@@ -197,7 +197,7 @@ def test_validation_error_forces_fallback_for_older_plugin_versions():
|
||||
assert manager.created == []
|
||||
assert warnings == [
|
||||
(
|
||||
'Der vorhandene Mandant "Auto-Import" wurde automatisch für Objekte ohne '
|
||||
'auflösbaren Mandanten ausgewählt.'
|
||||
'The existing tenant "Auto-Import" was selected automatically for objects without a '
|
||||
'resolvable tenant.'
|
||||
)
|
||||
]
|
||||
@@ -49,7 +49,7 @@ def test_missing_external_reference_is_omitted_and_warned_once():
|
||||
assert second_available is True
|
||||
assert manager.calls == 1
|
||||
assert warnings == [
|
||||
"Externe Referenz ausgelassen: users.user mit {'username': 'lke'} (nicht gefunden)."
|
||||
"External reference omitted: users.user with {'username': 'lke'} (not found)."
|
||||
]
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ def test_ambiguous_external_reference_is_omitted():
|
||||
assert value is MISSING_REFERENCE
|
||||
assert available is True
|
||||
assert warnings == [
|
||||
"Externe Referenz ausgelassen: users.group mit {'name': 'NetBox'} (nicht eindeutig)."
|
||||
"External reference omitted: users.group with {'name': 'NetBox'} (not unique)."
|
||||
]
|
||||
|
||||
|
||||
@@ -84,8 +84,8 @@ def test_reference_to_skipped_record_is_omitted_and_warned_once():
|
||||
assert second_available is True
|
||||
assert warnings == [
|
||||
(
|
||||
"dcim.rackreservation:17 (dcim.rackreservation) wurde wegen fehlender "
|
||||
"Pflichtreferenz übersprungen: user."
|
||||
"dcim.rackreservation:17 (dcim.rackreservation) was skipped because of a missing "
|
||||
"required reference: user."
|
||||
),
|
||||
"Referenzen auf das übersprungene Objekt dcim.rackreservation:17 wurden ausgelassen.",
|
||||
"References to the skipped object dcim.rackreservation:17 were omitted.",
|
||||
]
|
||||
Reference in new issue
Block a user