ipadm: translate to English, fix help alignment

- All ipadm-internal messages (usage, prompts, errors) are now English
- Usage text is built programmatically from a (left, desc) row list with
  computed column width instead of hand-aligned spaces, so it can't drift
  out of alignment again when rows are added/changed
- README's literal usage block updated to match; rest of the repo docs
  stay German
This commit is contained in:
2026-08-18 11:49:47 +02:00
parent 8591223aca
commit 1a39f54858
9 changed files with 137 additions and 99 deletions
+8 -8
View File
@@ -26,19 +26,19 @@ const portFwdHeader = "# ipadm port-forward database - managed with `ipadm`, do
func parsePortFwdLine(line string) (PortForward, error) {
parts := strings.Split(line, "\t")
if len(parts) != 4 {
return PortForward{}, fmt.Errorf("ungültige Zeile (erwarte 4 Tab-getrennte Felder): %q", line)
return PortForward{}, fmt.Errorf("invalid line (expected 4 tab-separated fields): %q", line)
}
wanPort, err := strconv.Atoi(parts[0])
if err != nil {
return PortForward{}, fmt.Errorf("ungültiger wan-port: %q", parts[0])
return PortForward{}, fmt.Errorf("invalid wan-port: %q", parts[0])
}
lanPort, err := strconv.Atoi(parts[3])
if err != nil {
return PortForward{}, fmt.Errorf("ungültiger lan-port: %q", parts[3])
return PortForward{}, fmt.Errorf("invalid lan-port: %q", parts[3])
}
proto := parts[1]
if !validProtos[proto] {
return PortForward{}, fmt.Errorf("ungültiges Protokoll: %q", proto)
return PortForward{}, fmt.Errorf("invalid protocol: %q", proto)
}
return PortForward{WanPort: wanPort, Proto: proto, Host: parts[2], LanPort: lanPort}, nil
}
@@ -62,7 +62,7 @@ func sortPortFwds(fwds []PortForward) {
func validatePort(label string, port int) error {
if port < 1 || port > 65535 {
return fmt.Errorf("ungültiger %s: %d (erlaubt: 1-65535)", label, port)
return fmt.Errorf("invalid %s: %d (allowed: 1-65535)", label, port)
}
return nil
}
@@ -111,7 +111,7 @@ func classifyPortFwdArgs(args []string, wanPort int) (lanPort int, proto string,
for _, a := range args {
if validProtos[a] {
if protoSet {
return 0, "", fmt.Errorf("Protokoll mehrfach angegeben: %q", a)
return 0, "", fmt.Errorf("protocol given more than once: %q", a)
}
proto = a
protoSet = true
@@ -119,13 +119,13 @@ func classifyPortFwdArgs(args []string, wanPort int) (lanPort int, proto string,
}
if n, convErr := strconv.Atoi(a); convErr == nil {
if lanPortSet {
return 0, "", fmt.Errorf("lan-port mehrfach angegeben: %q", a)
return 0, "", fmt.Errorf("lan-port given more than once: %q", a)
}
lanPort = n
lanPortSet = true
continue
}
return 0, "", fmt.Errorf("unbekanntes Argument %q (erwarte lan-port oder tcp/udp/both)", a)
return 0, "", fmt.Errorf("unrecognized argument %q (expected lan-port or tcp/udp/both)", a)
}
return lanPort, proto, nil
}