1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-16 08:09:32 +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 _)
;;
(defun _(txt &aux translated language-list)
(defun _(txt &aux newtxt)
(when (boundp '*locale*)
(if (not (listp *locale*))
(format t "Warning: Invalid *locale* (not a list).~%")
(let ((locale (get '*audacity* 'language)))
(if (not (setf language-list (assoc locale *locale* :test 'string-equal)))
(format t "Warning: No language-list for ~s in *locale*.~%" locale)
(if (/= (length language-list) 2)
(format t "Error: Invalid ~s language list in *locale*.~%" locale)
; Get just the list of substitution pairs
(let ((language-list (second language-list)))
(if (not (listp language-list))
(format t "Warning: No translations for ~s in *locale*.~%" locale)
(let ((translation (assoc txt language-list :test 'string=)))
(if (not translation)
(format t "Warning: No ~a translations for ~s.~%" locale txt)
(if (not (and (listp translation)
(= (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))))
(when (not (listp *locale*))
(error "bad argument type" *locale*))
(let* ((cc (get '*audacity* 'language))
(translations (second (assoc cc *locale* :test 'string-equal))))
(if translations
(let ((translation (second (assoc txt translations :test 'string=))))
(if translation
(if (stringp translation)
(setf newtxt translation)
(error "bad argument type" translation))
(format t "No ~s translation of ~s.~%" cc txt)))
(progn
(setf *locale* '*unbound*)
(format t "No ~s translations.~%" cc)))))
(if newtxt newtxt (underscore txt)))
;;; Some helpers for parsing strings returned by (aud-do "GetInfo: ...