From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:470:142:3::10]:57976) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9cuD-0002It-4D for guix-patches@gnu.org; Sun, 15 Sep 2019 18:22:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i9cuC-00079P-3v for guix-patches@gnu.org; Sun, 15 Sep 2019 18:22:05 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:40024) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i9cuB-00079J-WD for guix-patches@gnu.org; Sun, 15 Sep 2019 18:22:04 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1i9cuB-0007gr-Qy for guix-patches@gnu.org; Sun, 15 Sep 2019 18:22:03 -0400 Subject: [bug#37413] [PATCH 5/9] ui: Add 'current-message-language'. Resent-Message-ID: From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Mon, 16 Sep 2019 00:21:02 +0200 Message-Id: <20190915222106.4463-5-ludo@gnu.org> In-Reply-To: <20190915222106.4463-1-ludo@gnu.org> References: <20190915222106.4463-1-ludo@gnu.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 37413@debbugs.gnu.org * 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