This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch main
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=e5c856f7368a71a6dbcb8fb1fd318f836a246f78

commit e5c856f7368a71a6dbcb8fb1fd318f836a246f78
Author: Guillem Jover <guil...@debian.org>
AuthorDate: Wed Feb 28 04:34:21 2024 +0100

    libdpkg: Add support for DPKG_NLS environment variable
    
    This implements the DPKG_NLS environment variable support that all other
    perl scripts already support, unifying the interface. This also covers
    the case where a frontend might want to be translated but get
    untranslated messages from dpkg itself.
---
 lib/dpkg/i18n.c           | 21 ++++++++++++++++++++-
 man/dpkg-deb.pod          |  6 ++++++
 man/dpkg-divert.pod       |  6 ++++++
 man/dpkg-query.pod        |  6 ++++++
 man/dpkg-realpath.pod     |  6 ++++++
 man/dpkg-split.pod        |  6 ++++++
 man/dpkg-statoverride.pod |  6 ++++++
 man/dpkg-trigger.pod      |  6 ++++++
 man/dpkg.pod              |  6 ++++++
 9 files changed, 68 insertions(+), 1 deletion(-)

diff --git a/lib/dpkg/i18n.c b/lib/dpkg/i18n.c
index 30e28bffc..9482d2562 100644
--- a/lib/dpkg/i18n.c
+++ b/lib/dpkg/i18n.c
@@ -21,6 +21,8 @@
 #include <config.h>
 #include <compat.h>
 
+#include <stdbool.h>
+
 #include <dpkg/i18n.h>
 
 #ifdef HAVE_USELOCALE
@@ -30,10 +32,27 @@
 static locale_t dpkg_C_locale;
 #endif
 
+static bool
+dpkg_use_nls(void)
+{
+       const char *env;
+
+       /* We mimic the behavior of the Dpkg::Gettext perl module. */
+       env = getenv("DPKG_NLS");
+       if (env == NULL)
+               return true;
+
+       if (strcmp(env, "0") == 0 || env[0] == '\0')
+               return false;
+
+       return true;
+}
+
 void
 dpkg_locales_init(const char *package)
 {
-       setlocale(LC_ALL, "");
+       if (dpkg_use_nls())
+               setlocale(LC_ALL, "");
        bindtextdomain(package, LOCALEDIR);
        textdomain(package);
 
diff --git a/man/dpkg-deb.pod b/man/dpkg-deb.pod
index e406f0bcf..40d29a77d 100644
--- a/man/dpkg-deb.pod
+++ b/man/dpkg-deb.pod
@@ -394,6 +394,12 @@ Sets the color mode (since dpkg 1.18.5).
 The currently accepted values are: B<auto> (default), B<always> and
 B<never>.
 
+=item B<DPKG_NLS>
+
+If set, it will be used to decide whether to activate Native Language Support,
+also known as internationalization (or i18n) support (since dpkg 1.22.7).
+The accepted values are: B<0> and B<1> (default).
+
 =item B<TMPDIR>
 
 If set, B<dpkg-deb> will use it as the directory in which to create
diff --git a/man/dpkg-divert.pod b/man/dpkg-divert.pod
index 39856573a..fe7fa0bd2 100644
--- a/man/dpkg-divert.pod
+++ b/man/dpkg-divert.pod
@@ -202,6 +202,12 @@ Sets the color mode (since dpkg 1.18.5).
 The currently accepted values are: B<auto> (default), B<always> and
 B<never>.
 
+=item B<DPKG_NLS>
+
+If set, it will be used to decide whether to activate Native Language Support,
+also known as internationalization (or i18n) support (since dpkg 1.22.7).
+The accepted values are: B<0> and B<1> (default).
+
 =back
 
 =head1 FILES
diff --git a/man/dpkg-query.pod b/man/dpkg-query.pod
index 599fed4ce..e7b19a004 100644
--- a/man/dpkg-query.pod
+++ b/man/dpkg-query.pod
@@ -544,6 +544,12 @@ Sets the color mode (since dpkg 1.18.5).
 The currently accepted values are: B<auto> (default), B<always> and
 B<never>.
 
+=item B<DPKG_NLS>
+
+If set, it will be used to decide whether to activate Native Language Support,
+also known as internationalization (or i18n) support (since dpkg 1.22.7).
+The accepted values are: B<0> and B<1> (default).
+
 =back
 
 =head2 Internal environment
diff --git a/man/dpkg-realpath.pod b/man/dpkg-realpath.pod
index 3961981ec..f801d8ee9 100644
--- a/man/dpkg-realpath.pod
+++ b/man/dpkg-realpath.pod
@@ -82,6 +82,12 @@ specified, it will be used as the filesystem root directory.
 Sets the color mode.
 The currently accepted values are: B<auto> (default), B<always> and B<never>.
 
+=item B<DPKG_NLS>
+
+If set, it will be used to decide whether to activate Native Language Support,
+also known as internationalization (or i18n) support (since dpkg 1.22.7).
+The accepted values are: B<0> and B<1> (default).
+
 =back
 
 =head1 SEE ALSO
diff --git a/man/dpkg-split.pod b/man/dpkg-split.pod
index dcd9c26ea..d05d29b3b 100644
--- a/man/dpkg-split.pod
+++ b/man/dpkg-split.pod
@@ -290,6 +290,12 @@ Sets the color mode (since dpkg 1.18.5).
 The currently accepted values are: B<auto> (default), B<always> and
 B<never>.
 
+=item B<DPKG_NLS>
+
+If set, it will be used to decide whether to activate Native Language Support,
+also known as internationalization (or i18n) support (since dpkg 1.22.7).
+The accepted values are: B<0> and B<1> (default).
+
 =item B<SOURCE_DATE_EPOCH>
 
 If set, it will be used as the timestamp (as seconds since the epoch) in
diff --git a/man/dpkg-statoverride.pod b/man/dpkg-statoverride.pod
index 5220c47ec..d98665494 100644
--- a/man/dpkg-statoverride.pod
+++ b/man/dpkg-statoverride.pod
@@ -221,6 +221,12 @@ Sets the color mode (since dpkg 1.18.5).
 The currently accepted values are: B<auto> (default), B<always> and
 B<never>.
 
+=item B<DPKG_NLS>
+
+If set, it will be used to decide whether to activate Native Language Support,
+also known as internationalization (or i18n) support (since dpkg 1.22.7).
+The accepted values are: B<0> and B<1> (default).
+
 =back
 
 =head1 FILES
diff --git a/man/dpkg-trigger.pod b/man/dpkg-trigger.pod
index bf4b83776..e1064f966 100644
--- a/man/dpkg-trigger.pod
+++ b/man/dpkg-trigger.pod
@@ -157,6 +157,12 @@ Sets the color mode (since dpkg 1.18.5).
 The currently accepted values are: B<auto> (default), B<always> and
 B<never>.
 
+=item B<DPKG_NLS>
+
+If set, it will be used to decide whether to activate Native Language Support,
+also known as internationalization (or i18n) support (since dpkg 1.22.7).
+The accepted values are: B<0> and B<1> (default).
+
 =back
 
 =head1 SEE ALSO
diff --git a/man/dpkg.pod b/man/dpkg.pod
index 75493cd42..c1cf602e9 100644
--- a/man/dpkg.pod
+++ b/man/dpkg.pod
@@ -1356,6 +1356,12 @@ Sets the color mode (since dpkg 1.18.5).
 The currently accepted values are: B<auto> (default), B<always> and
 B<never>.
 
+=item B<DPKG_NLS>
+
+If set, it will be used to decide whether to activate Native Language Support,
+also known as internationalization (or i18n) support (since dpkg 1.22.7).
+The accepted values are: B<0> and B<1> (default).
+
 =item B<DPKG_DEBUG>
 
 Sets the debug mask (since dpkg 1.21.10) from an octal value.

-- 
Dpkg.Org's dpkg

Reply via email to