source: project/release/4/locale/trunk/locale-categories.scm @ 35403

Last change on this file since 35403 was 35403, checked in by kon, 7 months ago

delay locale-setup until 1st need, add current-second-dst?, test has dst flag now

File size: 1.9 KB
Line 
1;;;; locale-categories.scm
2;;;; Kon Lovett, May '06
3
4(module locale-categories
5
6(;export
7  ;
8  make-locale-dictionary
9  locale-dictionary?
10  set-locale-dictionary-category!
11  locale-dictionary-category
12  ;
13  current-locale-dictionary
14  locale-category-ref
15  set-locale-category!)
16
17(import scheme chicken)
18(use
19  #;srfi-9
20  (only miscmacros define-parameter)
21  lookup-table
22  type-checks
23  type-errors
24  locale-components)
25
26;;;
27
28(define-record-type locale-dictionary
29  (%make-locale-dictionary tbl)
30  locale-dictionary?
31  (tbl locale-dictionary-table) )
32
33(define (make-locale-dictionary)
34  (%make-locale-dictionary (make-dict)) )
35
36(define-check+error-type locale-dictionary)
37
38;;
39
40(define (set-locale-dictionary-category! rec key val)
41  (check-symbol 'set-locale-dictionary-category! key)
42  (let (
43    (tbl
44      (locale-dictionary-table
45        (check-locale-dictionary 'set-locale-dictionary-category! rec))) )
46    (cond
47      ((not val)
48        (dict-delete! tbl key))
49      (else
50        (check-locale-components 'set-locale-dictionary-category! val)
51        (dict-set! tbl key val) ) ) ) )
52
53;; A locale-component or #f
54
55(define (locale-dictionary-category rec key #!optional def)
56  (check-locale-dictionary 'locale-dictionary-category rec)
57  (check-symbol 'locale-dictionary-category key)
58  (dict-ref (locale-dictionary-table rec) key def) )
59
60;;;
61
62;;
63
64(define-parameter current-locale-dictionary (make-locale-dictionary)
65  (lambda (x)
66    (cond
67      ((locale-dictionary? x)
68        x )
69      (else
70        (warning 'current-locale-dictionary (make-error-type-message "locale-dictionary") x)
71        (current-locale-dictionary) ) ) ) )
72
73;;
74
75(define (set-locale-category! what value)
76  (set-locale-dictionary-category! (current-locale-dictionary) what value) )
77
78;; A locale-component or #f
79
80(define (locale-category-ref what #!optional def)
81        (locale-dictionary-category (current-locale-dictionary) what def) )
82
83) ;module locale-categories
Note: See TracBrowser for help on using the repository browser.