GNU bug report logs -
#24186
setlocale can't be localised
Previous Next
Full log
View this message in rfc822 format
Hi,
Zefram <zefram <at> fysh.org> 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’.
This bug report was last modified 8 years and 247 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.