Changeset 13860 in project for release/3/locale/trunk/locale.scm


Ignore:
Timestamp:
03/22/09 20:58:55 (12 years ago)
Author:
Kon Lovett
Message:

Save. Mvd params into locale.scm

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release/3/locale/trunk/locale.scm

    r13852 r13860  
    1313  (export
    1414    UNKNOWN-LOCAL-TZ-NAME
    15     BUILTIN-SOURCE) )
     15    BUILTIN-SOURCE
     16    current-timezone
     17    current-locale
     18    current-timezone-components
     19    current-locale-components) )
    1620
    17 (require-extension posix locale-posix locale-components locale-parameters)
     21(require-extension posix miscmacros locale-posix locale-components locale-categories locale-errors)
     22
     23;;;
     24
     25(define (check-string-or-false loc obj)
     26  (unless (or (not obj) (string? obj))
     27    (type-error loc "string or #f" obj) ) )
     28
     29;;
     30
     31(define (current-timezone . args)
     32  (cond ((null? args)
     33          (and-let* ((lc (locale-category-ref 'timezone)))
     34            (locale-component-ref lc 'name) ) )
     35        (else
     36          (let-optionals args ((str #f) (src "USER"))
     37            (check-string-or-false 'current-timezone str)
     38            (let ((lc (and str (posix-timezone-string->locale-components str src))))
     39              (set-locale-category! 'timezone lc) ) ) ) ) )
     40
     41;; A'la MzScheme
     42;; Treat locale as messages category
     43
     44(define (current-locale . args)
     45  (cond ((null? args)
     46          (and-let* ((lc (locale-category-ref 'messages)))
     47            (locale-component-ref lc 'name) ) )
     48        (else
     49          (let-optionals args ((str #f) (src "USER"))
     50            (check-string-or-false 'current-locale str)
     51            (let ((lc (and str (posix-locale-string->locale-components str src))))
     52              (set-locale-category! 'messages lc) ) ) ) ) )
     53
     54;;
     55
     56(define (current-timezone-components) (locale-category-ref 'timezone))
     57
     58(define (current-locale-components) (locale-category-ref 'messages))
    1859
    1960;;; When no environment info use Plan B
     
    68109  (and-let* ((msglc (locale-category-ref 'messages)))
    69110    (let ((lc (make-locale-components (locale-component-ref msglc 'name) BUILTIN-SOURCE 'language)))
    70       (set-locale-components! lc 'locales (list msglc))
     111      (update-locale-components! lc 'locales (list msglc))
    71112      (set-locale-category! 'language lc) ) ) )
    72113
Note: See TracChangeset for help on using the changeset viewer.