From 7e960384fa89c02c2fc2be1f61fe18645f8a13fe Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Sat, 13 Apr 2002 11:13:33 +0000 Subject: added message catalog support --- chess-message.el | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 chess-message.el (limited to 'chess-message.el') diff --git a/chess-message.el b/chess-message.el new file mode 100644 index 0000000..79786ff --- /dev/null +++ b/chess-message.el @@ -0,0 +1,47 @@ +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;; Code shared by all chess displays +;; +;; $Revision$ + +(defgroup chess-message nil + "Support for message catalogs in chess.el." + :group 'chess) + +(defcustom chess-message-language 'english + "The language to use when reporting messages." + :type 'symbol + :group 'chess-message) + +;;; Code: + +(defvar chess-message-catalog nil) + +(defun chess-message-catalog (catalog definitions) + (let ((entry (assq catalog chess-message-catalog))) + (if entry + (dolist (def definitions) + (let ((str (assq (car def) (cdr entry)))) + (if str + (setcdr str (cdr def)) + (push def (cdr entry))))) + (push (cons catalog definitions) chess-message-catalog)))) + +(defun chess-string (key &rest arguments) + (let* ((entry (assq chess-message-language chess-message-catalog)) + (msg (and entry (cdr (assq key (cdr entry)))))) + (if msg + (apply 'format msg arguments) + "message not found"))) + +(defsubst chess-message (key &rest arguments) + (message (apply 'chess-string key arguments))) + +(defsubst chess-error (key &rest arguments) + (error (apply 'chess-string key arguments))) + +(put 'chess-message-catalog 'lisp-indent-function 1) + +(provide 'chess-message) + +;;; chess-message.el ends here -- cgit v1.2.3