Files
dxfmakros/Lisp/ssg_lang.lsp
T
2026-07-15 15:18:08 +02:00

129 lines
3.8 KiB
Common Lisp

;; ============================================================
;; SSG_LANG.LSP - Sprachumschaltung (Deutsch/Englisch)
;; Zentrale Textverwaltung fuer benutzersichtbare Meldungen.
;; Kern-Modul, wird direkt nach ssg_core geladen.
;; ============================================================
;; ------------------------------------------------------------
;; TEXTTABELLE
;; Eintrag: (list key (cons "de_DE" "...") (cons "en_GB" "..."))
;; ------------------------------------------------------------
(setq *ssg-texts*
(list
;; SSG_LIB_Commands.lsp - SSG_DIM_SWITCH
(list "dim-switch-modus"
(cons "de_DE" "\nModus umgeschaltet auf: %1")
(cons "en_GB" "\nMode switched to: %1")
)
(list "dim-switch-blocks"
(cons "de_DE" "\n DXFM_BLOCKS = %1")
(cons "en_GB" "\n DXFM_BLOCKS = %1")
)
(list "dim-switch-omniflo"
(cons "de_DE" "\n DXFM_OMNIFLO = %1")
(cons "en_GB" "\n DXFM_OMNIFLO = %1")
)
;; SSG_LIB_Commands.lsp - SSG_SPRACHE
(list "sprache-gewechselt"
(cons "de_DE" "\nSprache umgeschaltet auf: %1")
(cons "en_GB" "\nLanguage switched to: %1")
)
;; Gefaellestrecke.lsp - Seite waehlen (AUS/EIN-Element)
(list "gf-seite-aus-header"
(cons "de_DE" "\n\nAUS-Element (AS_Element_90_*) - Seite waehlen:")
(cons "en_GB" "\n\nOutput element (AS_Element_90_*) - choose side:")
)
(list "gf-seite-ein-header"
(cons "de_DE" "\n\nEIN-Element (ES_Element_90_*) - Seite waehlen:")
(cons "en_GB" "\n\nInput element (ES_Element_90_*) - choose side:")
)
(list "gf-seite-links"
(cons "de_DE" "\n 1 - Links")
(cons "en_GB" "\n 1 - Left")
)
(list "gf-seite-rechts"
(cons "de_DE" "\n 2 - Rechts")
(cons "en_GB" "\n 2 - Right")
)
;; Wiederkehrender Menue-Prompt (mehrere Module)
(list "prompt-wahl-1-2"
(cons "de_DE" "\nIhre Wahl (1/2) [1]: ")
(cons "en_GB" "\nYour choice (1/2) [1]: ")
)
;; ssg_core.lsp - ssg-ques (Ja/Nein-Abfrage)
(list "ques-yn-default-yes"
(cons "de_DE" " Y/N <Y>: ")
(cons "en_GB" " Y/N <Y>: ")
)
(list "ques-yn-default-no"
(cons "de_DE" " Y/N <N>: ")
(cons "en_GB" " Y/N <N>: ")
)
)
)
;; ------------------------------------------------------------
;; AKTUELLE SPRACHE
;; Default de_DE, Init aus DXFM_LANG. Ein erneutes Laden dieses
;; Moduls ueberschreibt eine zur Laufzeit gesetzte Sprache nicht.
;; ------------------------------------------------------------
(if (null *ssg-lang*)
(setq *ssg-lang* (getenv "DXFM_LANG"))
)
(if (or (null *ssg-lang*) (= *ssg-lang* ""))
(setq *ssg-lang* "de_DE")
)
;; ------------------------------------------------------------
;; ssg-text - Text zu einem Key in der aktuellen Sprache liefern
;; Fallback-Kette: *ssg-lang* -> de_DE -> Key selbst
;; ------------------------------------------------------------
(defun ssg-text (key / eintrag wert)
(setq eintrag (assoc key *ssg-texts*))
(if eintrag
(progn
(setq wert (cdr (assoc *ssg-lang* (cdr eintrag))))
(if (null wert)
(setq wert (cdr (assoc "de_DE" (cdr eintrag))))
)
(if (null wert) key wert)
)
key
)
)
;; Alle Vorkommen von alt in str durch neu ersetzen
(defun ssg-str-replace-all (neu alt str / pos ergebnis)
(setq ergebnis "")
(while (setq pos (vl-string-search alt str))
(setq ergebnis (strcat ergebnis (substr str 1 pos) neu))
(setq str (substr str (+ pos 1 (strlen alt))))
)
(strcat ergebnis str)
)
;; ssg-textf - Text mit Platzhaltern %1 %2 ... aus einer Werteliste fuellen
(defun ssg-textf (key werte / txt i platzhalter)
(setq txt (ssg-text key))
(setq i 1)
(foreach w werte
(setq platzhalter (strcat "%" (itoa i)))
(setq txt (ssg-str-replace-all (vl-princ-to-string w) platzhalter txt))
(setq i (1+ i))
)
txt
)
(princ)