1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-08-02 17:09:26 +02:00

Throw error if Nyquist *LOCALE* is malformed

Partial translations are allowed.
This commit is contained in:
Steve Daulton 2018-10-11 02:43:07 +01:00
parent e20a98588c
commit 37ec7da3c3

View File

@ -19,30 +19,23 @@
;; ;;
(setfn underscore _) (setfn underscore _)
;; ;;
(defun _(txt &aux translated language-list) (defun _(txt &aux newtxt)
(when (boundp '*locale*) (when (boundp '*locale*)
(if (not (listp *locale*)) (when (not (listp *locale*))
(format t "Warning: Invalid *locale* (not a list).~%") (error "bad argument type" *locale*))
(let ((locale (get '*audacity* 'language))) (let* ((cc (get '*audacity* 'language))
(if (not (setf language-list (assoc locale *locale* :test 'string-equal))) (translations (second (assoc cc *locale* :test 'string-equal))))
(format t "Warning: No language-list for ~s in *locale*.~%" locale) (if translations
(if (/= (length language-list) 2) (let ((translation (second (assoc txt translations :test 'string=))))
(format t "Error: Invalid ~s language list in *locale*.~%" locale) (if translation
; Get just the list of substitution pairs (if (stringp translation)
(let ((language-list (second language-list))) (setf newtxt translation)
(if (not (listp language-list)) (error "bad argument type" translation))
(format t "Warning: No translations for ~s in *locale*.~%" locale) (format t "No ~s translation of ~s.~%" cc txt)))
(let ((translation (assoc txt language-list :test 'string=))) (progn
(if (not translation) (setf *locale* '*unbound*)
(format t "Warning: No ~a translations for ~s.~%" locale txt) (format t "No ~s translations.~%" cc)))))
(if (not (and (listp translation) (if newtxt newtxt (underscore txt)))
(= (length translation) 2)))
(format t "Error: Invalid translation for ~s in *locale*.~%" txt)
(setf translated (second translation))))))))))))
(if translated
translated
(progn (setf *locale* '*unbound*)
(underscore txt))))
;;; Some helpers for parsing strings returned by (aud-do "GetInfo: ... ;;; Some helpers for parsing strings returned by (aud-do "GetInfo: ...