[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#37413] [PATCH v2 06/11] ui: Add 'current-message-language'.
From: |
Ludovic Courtès |
Subject: |
[bug#37413] [PATCH v2 06/11] ui: Add 'current-message-language'. |
Date: |
Sat, 21 Sep 2019 23:12:23 +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 4be31db047..069d542131 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -121,6 +121,10 @@
roll-back*
switch-to-generation*
delete-generation*
+
+ %default-message-language
+ current-message-language
+
run-guix-command
run-guix
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."
(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, (continued)
- [bug#37413] [PATCH 0/9] Channel news distribution mechanism, pelzflorian (Florian Pelz), 2019/09/17
- [bug#37413] [PATCH 0/9] Channel news distribution mechanism, pelzflorian (Florian Pelz), 2019/09/17
- [bug#37413] [PATCH 0/9] Channel news distribution mechanism, Ludovic Courtès, 2019/09/18
- [bug#37413] [PATCH 0/9] Channel news distribution mechanism, pelzflorian (Florian Pelz), 2019/09/18
- [bug#37413] [PATCH 0/9] Channel news distribution mechanism, Ludovic Courtès, 2019/09/18
- [bug#37413] [PATCH 0/9] Channel news distribution mechanism, Ludovic Courtès, 2019/09/18
[bug#37413] [PATCH v2 00/11] Channel news distribution mechanism, Ludovic Courtès, 2019/09/21
- [bug#37413] [PATCH v2 01/11] pull: '--news' shows the list of channels added or removed., Ludovic Courtès, 2019/09/21
- [bug#37413] [PATCH v2 02/11] git: 'update-cached-checkout' avoids network access when unnecessary., Ludovic Courtès, 2019/09/21
- [bug#37413] [PATCH v2 07/11] pull: Display channel news., Ludovic Courtès, 2019/09/21
- [bug#37413] [PATCH v2 06/11] ui: Add 'current-message-language'.,
Ludovic Courtès <=
- [bug#37413] [PATCH v2 08/11] pull: '-l' displays channel news., Ludovic Courtès, 2019/09/21
- [bug#37413] [PATCH v2 03/11] git: Add 'commit-difference'., Ludovic Courtès, 2019/09/21
- [bug#37413] [PATCH v2 05/11] channels: Allow news entries to refer to a tag., Ludovic Courtès, 2019/09/21
- [bug#37413] [PATCH v2 04/11] channels: Add support for a news file., Ludovic Courtès, 2019/09/21
- [bug#37413] [PATCH v2 10/11] Add '.guix-channel' file., Ludovic Courtès, 2019/09/21
- [bug#37413] [PATCH v2 11/11] DRAFT etc: Add channel news file., Ludovic Courtès, 2019/09/21
- [bug#37413] [PATCH v2 11/11] DRAFT etc: Add channel news file., pelzflorian (Florian Pelz), 2019/09/22
- [bug#37413] [PATCH v2 11/11] DRAFT etc: Add channel news file., Ludovic Courtès, 2019/09/23
[bug#37413] [PATCH v2 09/11] pull: Display news titles directly upon 'pull'., Ludovic Courtès, 2019/09/21