bug-guile
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#24186: setlocale can't be localised


From: Ludovic Courtès
Subject: bug#24186: setlocale can't be localised
Date: Tue, 11 Oct 2016 10:06:15 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux)

Hi,

Zefram <address@hidden> skribis:

>     (define (call-with-locale cat val body)
>       (let ((oldval #f))
>       (dynamic-wind
>         (lambda () (set! oldval (setlocale cat)) (setlocale cat val))
>         body (lambda () (setlocale cat oldval)))))
>
>     (define (day-of-week-string)
>       (strftime "%A" (localtime (current-time)))) 
>
>     (define (day-of-week-string-for-locale loc)
>       (call-with-locale LC_TIME loc day-of-week-string))
>
>     ;; user-locale is application-specific code defined elsewhere
>     (define (day-of-week-string-for-user user)
>       (day-of-week-string-for-locale (user-locale user)))

This does not really answer your question, but (ice-9 i18n) provides
first-class locale objects, which avoid the whole global locale issue
(info "(guile) Internationalization").

Currently important procedures such as ‘strftime’ or SRFI-19’s
‘date->string’ cannot use such locale objects, though.  I think it would
make sense to add an optional locale object argument to ‘srftime’ and
‘date->string’ (though we should create a (srfi srfi-19 gnu) module for
that to make it clear that this is a GNU extension.)

That wouldn’t help with the ‘setlocale’ issue you describe per se, but
this would address such use cases in a different way.

WDYT?

Ludo’.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]