/[cl-l10n]/cl-l10n/locale.lisp
ViewVC logotype

Diff of /cl-l10n/locale.lisp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.6 by sross, Thu Dec 30 11:56:38 2004 UTC revision 1.7 by sross, Tue Jan 4 15:32:15 2005 UTC
# Line 7  Line 7 
7  ;;  Parsers (money and time)  ;;  Parsers (money and time)
8  ;;  locale aliases  ;;  locale aliases
9  ;;  Optimizing print-time  ;;  Optimizing print-time
10    ;;  Thread safety
11    
12  (in-package :cl-l10n )  (in-package :cl-l10n )
13    
 ;; Variables  
14  (defvar *locale-path*  (defvar *locale-path*
15    (let ((path *load-pathname*))    (merge-pathnames (make-pathname :directory '(:relative "locales"))
16      (make-pathname :host (pathname-host path)                     (directory-namestring *load-pathname*)))
                    :device (pathname-device path)  
                    :directory  
                    (append (pathname-directory path)  
                            '("locales"))  
                    :defaults #P"")))  
17    
18  (defvar *locale* nil)  (defvar *locale* nil)
19    
# Line 65  Line 60 
60      (princ (category-name obj) stream)))      (princ (category-name obj) stream)))
61    
62    
63  ;; Macros  (declaim (inline get-locale))
64  (defmacro get-locale (name)  (defun get-locale (name)
65    `(gethash ,name *locales*))    (gethash name *locales*))
66    
67  (defmacro get-category (name locale)  (defun (setf get-locale) (new-val name)
68    `(gethash ,name (categories ,locale)))    (setf (gethash name *locales*)
69            new-val))
70  (defmacro get-cat-val (value cat)  
71    `(gethash ,value (vals ,cat)))  (defgeneric get-category (locale name)
72      (:documentation "Find category called NAME in locale LOCALE.")
73      (:method ((locale locale) (name string))
74        (gethash name (categories locale))))
75    
76    (defmethod (setf get-category) ((new-val category) (locale locale) (name string))
77      (setf (gethash name (categories locale))
78            new-val))
79    
80    (defgeneric category-value (category key)
81      (:documentation "Lookup attribute named by string KEY in category CATEGORY.")
82      (:method ((category category) (key string))
83        (gethash key (vals category))))
84    
85    (defmethod (setf category-value) ((new-val t) (category category) (key string))
86      (setf (gethash key (vals category))
87            new-val))
88    
89  (defun locale-value (locale cat key)  (defun locale-value (locale cat key)
90    (awhen (get-category cat locale)    (awhen (get-category locale cat)
91      (get-cat-val key it)))      (category-value it key)))
92    
93  (defun getenv (word)  (defun getenv (word)
94    #+sbcl (sb-ext:posix-getenv word)    #+sbcl (sb-ext:posix-getenv word)

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

  ViewVC Help
Powered by ViewVC 1.1.5