[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#37413] [PATCH 5/9] ui: Add 'current-message-language'.
From: |
Ludovic Courtès |
Subject: |
[bug#37413] [PATCH 5/9] ui: Add 'current-message-language'. |
Date: |
Mon, 16 Sep 2019 00:21:02 +0200 |
* guix/ui.scm (%default-message-language): New variable.
(current-message-language): New procedure.
---
guix/ui.scm | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/guix/ui.scm b/guix/ui.scm
index 7920335928..42043b546c 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -120,6 +120,10 @@
roll-back*
switch-to-generation*
delete-generation*
+
+ %default-message-language
+ current-message-language
+
run-guix-command
run-guix
guix-main))
@@ -427,6 +431,20 @@ exiting. ARGS is the list of arguments received by the
'throw' handler."
report them in a user-friendly way."
(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)
"Install the current locale settings."
(catch 'system-error
--
2.23.0
- [bug#37413] [PATCH 0/9] Channel news distribution mechanism, Ludovic Courtès, 2019/09/15
- [bug#37413] [PATCH 1/9] pull: '--news' shows the list of channels added or removed., Ludovic Courtès, 2019/09/15
- [bug#37413] [PATCH 2/9] git: 'update-cached-checkout' avoids network access when unnecessary., Ludovic Courtès, 2019/09/15
- [bug#37413] [PATCH 5/9] ui: Add 'current-message-language'.,
Ludovic Courtès <=
- [bug#37413] [PATCH 7/9] pull: '-l' displays channel news., Ludovic Courtès, 2019/09/15
- [bug#37413] [PATCH 6/9] pull: Display channel news., Ludovic Courtès, 2019/09/15
- [bug#37413] [PATCH 3/9] git: Add 'commit-difference'., Ludovic Courtès, 2019/09/15
- [bug#37413] [PATCH 8/9] Add '.guix-channel' file., Ludovic Courtès, 2019/09/15
- [bug#37413] [PATCH 9/9] DRAFT etc: Add channel news file., Ludovic Courtès, 2019/09/15
- [bug#37413] [PATCH 4/9] channels: Add support for a news file., Ludovic Courtès, 2019/09/15
- [bug#37413] [PATCH 0/9] Channel news distribution mechanism, Ricardo Wurmus, 2019/09/16