aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--guix-build.in2
-rw-r--r--guix-download.in2
-rw-r--r--guix-gc.in2
-rw-r--r--guix-import.in2
-rw-r--r--guix-package.in2
-rw-r--r--guix/ui.scm11
6 files changed, 16 insertions, 5 deletions
diff --git a/guix-build.in b/guix-build.in
index 4d3db0aa6d..eb8d2fa016 100644
--- a/guix-build.in
+++ b/guix-build.in
@@ -220,7 +220,7 @@ Build the given PACKAGE-OR-DERIVATION and return their output paths.\n"))
name version)
(leave (_ "~A: unknown package~%") name))))))
- (setlocale LC_ALL "")
+ (install-locale)
(textdomain "guix")
(setvbuf (current-output-port) _IOLBF)
(setvbuf (current-error-port) _IOLBF)
diff --git a/guix-download.in b/guix-download.in
index f8859618d7..4b814699ca 100644
--- a/guix-download.in
+++ b/guix-download.in
@@ -134,7 +134,7 @@ and the hash of its contents.\n"))
(alist-cons 'argument arg result))
%default-options))
- (setlocale LC_ALL "")
+ (install-locale)
(textdomain "guix")
(setvbuf (current-output-port) _IOLBF)
(setvbuf (current-error-port) _IOLBF)
diff --git a/guix-gc.in b/guix-gc.in
index ab7ce3214f..1a4a5413d9 100644
--- a/guix-gc.in
+++ b/guix-gc.in
@@ -155,7 +155,7 @@ interpreted."
(alist-cons 'argument arg result))
%default-options))
- (setlocale LC_ALL "")
+ (install-locale)
(textdomain "guix")
(setvbuf (current-output-port) _IOLBF)
(setvbuf (current-error-port) _IOLBF)
diff --git a/guix-import.in b/guix-import.in
index af5c5897e0..97619a9a59 100644
--- a/guix-import.in
+++ b/guix-import.in
@@ -115,7 +115,7 @@ Import and convert the Nix expression ATTRIBUTE of NIXPKGS.\n"))
(alist-cons 'argument arg result))
%default-options))
- (setlocale LC_ALL "")
+ (install-locale)
(textdomain "guix")
(setvbuf (current-output-port) _IOLBF)
(setvbuf (current-error-port) _IOLBF)
diff --git a/guix-package.in b/guix-package.in
index 913872c925..ab0191faa2 100644
--- a/guix-package.in
+++ b/guix-package.in
@@ -598,7 +598,7 @@ Install, remove, or upgrade PACKAGES in a single transaction.\n"))
#t))
(_ #f))))
- (setlocale LC_ALL "")
+ (install-locale)
(textdomain "guix")
(setvbuf (current-output-port) _IOLBF)
(setvbuf (current-error-port) _IOLBF)
diff --git a/guix/ui.scm b/guix/ui.scm
index 761b1ce444..3ec7be771b 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -26,6 +26,7 @@
#:use-module (ice-9 match)
#:export (_
N_
+ install-locale
leave
show-version-and-exit
show-bug-report-information
@@ -45,6 +46,16 @@
(define _ (cut gettext <> %gettext-domain))
(define N_ (cut ngettext <> <> <> %gettext-domain))
+(define (install-locale)
+ "Install the current locale settings."
+ (catch 'system-error
+ (lambda _
+ (setlocale LC_ALL ""))
+ (lambda args
+ (format (current-error-port)
+ (_ "warning: failed to install locale: ~a~%")
+ (strerror (system-error-errno args))))))
+
(define-syntax-rule (leave fmt args ...)
"Format FMT and ARGS to the error port and exit."
(begin