ui: Add 'current-message-language'.
* guix/ui.scm (%default-message-language): New variable. (current-message-language): New procedure.
This commit is contained in:
parent
9719e8d37a
commit
a725504a3a
18
guix/ui.scm
18
guix/ui.scm
|
@ -121,6 +121,10 @@
|
||||||
roll-back*
|
roll-back*
|
||||||
switch-to-generation*
|
switch-to-generation*
|
||||||
delete-generation*
|
delete-generation*
|
||||||
|
|
||||||
|
%default-message-language
|
||||||
|
current-message-language
|
||||||
|
|
||||||
run-guix-command
|
run-guix-command
|
||||||
run-guix
|
run-guix
|
||||||
guix-main))
|
guix-main))
|
||||||
|
@ -428,6 +432,20 @@ exiting. ARGS is the list of arguments received by the 'throw' handler."
|
||||||
report them in a user-friendly way."
|
report them in a user-friendly way."
|
||||||
(call-with-unbound-variable-handling (lambda () exp ...)))
|
(call-with-unbound-variable-handling (lambda () exp ...)))
|
||||||
|
|
||||||
|
(define %default-message-language
|
||||||
|
;; Default language to use for messages.
|
||||||
|
(make-parameter "en"))
|
||||||
|
|
||||||
|
(define (current-message-language)
|
||||||
|
"Return the language used for messages according to the current locale.
|
||||||
|
Return %DEFAULT-MESSAGE-LANGUAGE if that information could not be obtained. The
|
||||||
|
result is an ISO-639-2 language code such as \"ar\", without the territory
|
||||||
|
part."
|
||||||
|
(let ((locale (setlocale LC_MESSAGES)))
|
||||||
|
(match (string-index locale #\_)
|
||||||
|
(#f locale)
|
||||||
|
(index (string-take locale index)))))
|
||||||
|
|
||||||
(define (install-locale)
|
(define (install-locale)
|
||||||
"Install the current locale settings."
|
"Install the current locale settings."
|
||||||
(catch 'system-error
|
(catch 'system-error
|
||||||
|
|
Loading…
Reference in New Issue