Skip to content
Snippets Groups Projects
Commit 8c1d7a9f authored by Niels Möller's avatar Niels Möller
Browse files

Ny hantering av språk

parent 57172957
No related branches found
No related tags found
No related merge requests found
(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))))))
alist)))
(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
lyskom-define-language."
(mapcar (function (lambda (symbol)
(cons symbol (lyskom-get-string symbol category))))
symbols))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment