Skip to content
Snippets Groups Projects
Unverified Commit a725504a authored by Ludovic Courtès's avatar Ludovic Courtès
Browse files

ui: Add 'current-message-language'.

* guix/ui.scm (%default-message-language): New variable.
(current-message-language): New procedure.
parent 9719e8d3
No related branches found
No related tags found
No related merge requests found
...@@ -121,6 +121,10 @@ (define-module (guix ui) ...@@ -121,6 +121,10 @@ (define-module (guix ui)
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 @@ (define-syntax-rule (with-unbound-variable-handling exp ...) ...@@ -428,6 +432,20 @@ (define-syntax-rule (with-unbound-variable-handling exp ...)
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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment