Commit 8c1d7a9f authored by Niels Möller's avatar Niels Möller
Browse files

Ny hantering av språk

parent 57172957
(defconst lyskom-category-properties
'((command . lyskom-command)
(menu . lyskom-menu)
(message . lyskom-message))
"Property names for saving different categories.")
(defun lyskom-define-language (category language alist)
"Associates names to symbols.
CATEGORY and LANGUAGE determines what kind of association to
create. ALIST is a mapping from symbols to strings."
(let ((property (cdr (assq category lyskom-category-properties))))
(mapcar (function (lambda (pair)
(let* ((symbol (car pair))
(string (cdr pair))
(llist (get symbol property))
(entry (assq language llist)))
(if entry (setcdr entry string)
(put symbol property
(cons (cons language string) llist))))))
(put 'lyskom-define-language 'lisp-indent-function 2)
(defun lyskom-get-string (symbol &optional category)
"Returns string assiciated with SYMBOL"
(if (not category) (setq category 'message))
(let ((prop (cond ((eq category 'command)
(get symbol 'lyskom-command))
((eq category 'menu)
(or (get symbol 'lyskom-menu)
(get symbol 'lyskom-command)))
((eq category 'message)
(get symbol 'lyskom-message))
(t nil))))
(or (cdr (assq lyskom-language prop))
(signal 'lyskom-internal-error
(list 'lyskom-get-string
(list symbol category ": string not found"))))))
(defun lyskom-get-strings (symbols &optional category)
"Returns an alist of (symbol . string) pairs
according to CATEGORY and lyskom-language. Sort of inverse to
(mapcar (function (lambda (symbol)
(cons symbol (lyskom-get-string symbol category))))
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment