guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[shepherd] 02/05: Complete i18n support.


From: Ludovic Courtès
Subject: [shepherd] 02/05: Complete i18n support.
Date: Fri, 2 Mar 2018 04:29:53 -0500 (EST)

civodul pushed a commit to branch master
in repository shepherd.

commit 6dd27d2925fc4fe589e5b2632df5307c41fba1bf
Author: Ludovic Courtès <address@hidden>
Date:   Fri Mar 2 10:18:23 2018 +0100

    Complete i18n support.
    
    * Makefile.am (instantiate): Substitute '%localedir%'.
    (AM_TESTS_ENVIRONMENT): Clear l10n-related variables.
    * modules/shepherd/config.scm.in (%localedir): New variable.
    * modules/shepherd/support.scm (%gettext-domain): New variable.
    (initialize-cli): New procedure.
    * modules/shepherd.scm (main): Use 'initialize-cli' instead of
    'setlocale'.
    * modules/shepherd/scripts/halt.scm (main): Likewise.
    * modules/shepherd/scripts/herd.scm (main): Likewise.
    * modules/shepherd/scripts/reboot.scm (main): Likewise.
---
 Makefile.am                         |  4 +++-
 modules/shepherd.scm                |  2 +-
 modules/shepherd/config.scm.in      |  2 ++
 modules/shepherd/scripts/halt.scm   |  4 ++--
 modules/shepherd/scripts/herd.scm   |  2 +-
 modules/shepherd/scripts/reboot.scm |  4 ++--
 modules/shepherd/support.scm        | 26 ++++++++++++++++++++++++++
 7 files changed, 37 insertions(+), 7 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 1c394e1..7583b59 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -138,6 +138,7 @@ instantiate =                                               
\
   -e 's,%modbuilddir%,${abs_top_builddir}/modules,g'   \
   -e 's,%localstatedir%,${localstatedir},g'            \
   -e 's,%sysconfdir%,${sysconfdir},g'                  \
+  -e 's,%localedir%,${localedir},g'                    \
   -e 's,%VERSION%,@VERSION@,g'                         \
   -e 's,%PACKAGE_BUGREPORT%,@PACKAGE_BUGREPORT@,g'     \
   -e 's,%PACKAGE_NAME%,@PACKAGE_NAME@,g'               \
@@ -195,7 +196,8 @@ TEST_EXTENSIONS = .sh
 EXTRA_DIST += $(TESTS)
 
 AM_TESTS_ENVIRONMENT =                         \
-  unset XDG_CONFIG_HOME; LC_ALL=C              \
+  unset XDG_CONFIG_HOME; unset LANGUAGE                \
+  LC_ALL=C LC_MESSAGES=C                       \
   PATH="$(abs_top_builddir):$$PATH"            \
   SHELL="$(SHELL)" GUILE="$(GUILE)"            \
   
GUILE_LOAD_PATH="$(abs_top_srcdir)/modules:$(abs_top_builddir)/modules:$$GUILE_LOAD_PATH"
 \
diff --git a/modules/shepherd.scm b/modules/shepherd.scm
index 02b27f6..df5420f 100644
--- a/modules/shepherd.scm
+++ b/modules/shepherd.scm
@@ -49,7 +49,7 @@
 
 ;; Main program.
 (define (main . args)
-  (false-if-exception (setlocale LC_ALL ""))
+  (initialize-cli)
 
   (let ((config-file #f)
        (socket-file default-socket-file)
diff --git a/modules/shepherd/config.scm.in b/modules/shepherd/config.scm.in
index 345078c..547b885 100644
--- a/modules/shepherd/config.scm.in
+++ b/modules/shepherd/config.scm.in
@@ -5,6 +5,7 @@
             Prefix-dir
             %localstatedir
             %sysconfdir
+            %localedir
             copyright
             bug-address
             package-name
@@ -14,6 +15,7 @@
 (define Prefix-dir "%PREFIX%")
 (define %localstatedir "%localstatedir%")
 (define %sysconfdir "%sysconfdir%")
+(define %localedir "%localedir%")
 
 (define copyright "Copyright (C) 2002, 2003 Wolfgang J�hrling")
 (define bug-address "%PACKAGE_BUGREPORT%")
diff --git a/modules/shepherd/scripts/halt.scm 
b/modules/shepherd/scripts/halt.scm
index 836a312..5115a53 100644
--- a/modules/shepherd/scripts/halt.scm
+++ b/modules/shepherd/scripts/halt.scm
@@ -1,5 +1,5 @@
 ;; halt.scm -- Halt or power off the system.
-;; Copyright (C) 2013, 2014, 2015, 2016 Ludovic Courtès <address@hidden>
+;; Copyright (C) 2013, 2014, 2015, 2016, 2018 Ludovic Courtès <address@hidden>
 ;;
 ;; This file is part of the GNU Shepherd.
 ;;
@@ -29,7 +29,7 @@
 
 ;; Main program.
 (define (main . args)
-  (false-if-exception (setlocale LC_ALL ""))
+  (initialize-cli)
 
   (parameterize ((program-name "halt"))
     (let ((socket-file %system-socket-file)
diff --git a/modules/shepherd/scripts/herd.scm 
b/modules/shepherd/scripts/herd.scm
index 1691182..36219b8 100644
--- a/modules/shepherd/scripts/herd.scm
+++ b/modules/shepherd/scripts/herd.scm
@@ -172,7 +172,7 @@ talking to shepherd"))
 
 ;; Main program.
 (define (main . args)
-  (false-if-exception (setlocale LC_ALL ""))
+  (initialize-cli)
 
   (parameterize ((program-name "herd"))
     (let ((socket-file default-socket-file)
diff --git a/modules/shepherd/scripts/reboot.scm 
b/modules/shepherd/scripts/reboot.scm
index e151cbb..bd63638 100644
--- a/modules/shepherd/scripts/reboot.scm
+++ b/modules/shepherd/scripts/reboot.scm
@@ -1,5 +1,5 @@
 ;; reboot.scm -- Reboot the system.
-;; Copyright (C) 2013, 2014, 2015, 2016 Ludovic Courtès <address@hidden>
+;; Copyright (C) 2013, 2014, 2015, 2016, 2018 Ludovic Courtès <address@hidden>
 ;;
 ;; This file is part of the GNU Shepherd.
 ;;
@@ -29,7 +29,7 @@
 
 ;; Main program.
 (define (main . args)
-  (false-if-exception (setlocale LC_ALL ""))
+  (initialize-cli)
 
   (parameterize ((program-name "reboot"))
     (let ((socket-file %system-socket-file)
diff --git a/modules/shepherd/support.scm b/modules/shepherd/support.scm
index bb01edc..c67575f 100644
--- a/modules/shepherd/support.scm
+++ b/modules/shepherd/support.scm
@@ -34,6 +34,9 @@
             mkdir-p
             with-directory-excursion
 
+            initialize-cli
+
+            %gettext-domain
             l10n
             local-output
             display-version
@@ -195,6 +198,29 @@ output port, and PROC's result is returned."
 
 
 
+(define %gettext-domain
+  ;; The gettext message domain.
+  "shepherd")
+
+(define (initialize-cli)
+  "Perform the usual initialization for stand-alone Shepherd commands."
+  ;; By default don't annoy users with deprecation warnings.  In practice,
+  ;; 'define-deprecated' in (ice-9 deprecated) arranges so that those warnings
+  ;; are emitted at expansion-time only, but there are cases where they could
+  ;; slip through, for instance when interpreting code.
+  (unless (getenv "GUILE_WARN_DEPRECATED")
+    (debug-disable 'warn-deprecated))
+
+  ;; In Guile 2.2+, the locale is installed by default.
+  (cond-expand
+    (guile-2.0 (false-if-exception (setlocale LC_ALL "")))
+    (else      #t))
+
+  (bindtextdomain %gettext-domain %localedir)
+  (textdomain %gettext-domain)
+  (setvbuf (current-output-port) _IOLBF)
+  (setvbuf (current-error-port) _IOLBF))
+
 ;; Localized version of STR.
 (define l10n gettext)
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]