[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: Set LC_MESSAGES via setenv before setlocale.
From: |
Gavin D. Smith |
Subject: |
branch master updated: Set LC_MESSAGES via setenv before setlocale. |
Date: |
Sun, 01 Dec 2024 07:59:43 -0500 |
This is an automated email from the git hooks/post-receive script.
gavin pushed a commit to branch master
in repository texinfo.
The following commit(s) were added to refs/heads/master by this push:
new d1a8b5a2ef Set LC_MESSAGES via setenv before setlocale.
d1a8b5a2ef is described below
commit d1a8b5a2ef3b4ee8f27e23294ec8a0af8cd1aa6d
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Sun Dec 1 12:59:29 2024 +0000
Set LC_MESSAGES via setenv before setlocale.
* tp/Texinfo/XS/main/translations.c (switch_messages_locale):
Set LC_ALL with setenv instead of LC_MESSAGES.
(translate_string): Save and restore LC_ALL in environment.
---
ChangeLog | 8 ++++++++
tp/Texinfo/XS/main/translations.c | 26 ++++++++++++++++++--------
2 files changed, 26 insertions(+), 8 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 9c8e832e53..0a392678e5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2024-12-01 Gavin Smith <gavinsmith0123@gmail.com>
+
+ Set LC_MESSAGES via setenv before setlocale.
+
+ * tp/Texinfo/XS/main/translations.c (switch_messages_locale):
+ Set LC_ALL with setenv instead of LC_MESSAGES.
+ (translate_string): Save and restore LC_ALL in environment.
+
2024-12-01 Gavin Smith <gavinsmith0123@gmail.com>
Set LC_MESSAGES via setenv before setlocale.
diff --git a/tp/Texinfo/XS/main/translations.c
b/tp/Texinfo/XS/main/translations.c
index 19020bda23..e538d9dc5c 100644
--- a/tp/Texinfo/XS/main/translations.c
+++ b/tp/Texinfo/XS/main/translations.c
@@ -104,7 +104,7 @@ switch_messages_locale (void)
if (working_locale)
{
- setenv_status = setenv ("LC_MESSAGES", working_locale, 1);
+ setenv_status = setenv ("LC_ALL", working_locale, 1)
|| setenv ("LANG", working_locale, 1);
locale = setlocale (LC_MESSAGES, "");
@@ -113,13 +113,13 @@ switch_messages_locale (void)
}
if (!locale || setenv_status)
{
- setenv_status = setenv ("LC_MESSAGES", "en_US.UTF-8", 1);
+ setenv_status = setenv ("LC_ALL", "en_US.UTF-8", 1)
|| setenv ("LANG", "en_US.UTF-8", 1);
locale = setlocale (LC_MESSAGES, "");
}
if (!locale || setenv_status)
{
- setenv_status = setenv ("LC_MESSAGES", "en_US", 1);
+ setenv_status = setenv ("LC_ALL", "en_US", 1)
|| setenv ("LANG", "en_US", 1);
locale = setlocale (LC_MESSAGES, "");
}
@@ -149,7 +149,7 @@ switch_messages_locale (void)
free (line);
continue;
}
- setenv_status = setenv ("LC_MESSAGES", line, 1);
+ setenv_status = setenv ("LC_ALL", line, 1)
|| setenv ("LANG", line, 1);
locale = setlocale (LC_MESSAGES, "");
if (locale && !setenv_status)
@@ -188,6 +188,7 @@ translate_string (const char *string, const char *in_lang,
const char *lang = in_lang;
char *saved_LANGUAGE;
char *saved_LANG;
+ char *saved_LC_ALL;
char *saved_LC_MESSAGES;
char *langs[2] = {0, 0};
char *main_lang = 0;
@@ -243,11 +244,12 @@ translate_string (const char *string, const char *in_lang,
switch_messages_locale to have LANGUAGE work in that case. */
saved_LANG = getenv ("LANG");
-
if (saved_LANG)
- {
- saved_LANG = strdup (saved_LANG);
- }
+ saved_LANG = strdup (saved_LANG);
+
+ saved_LC_ALL = getenv ("LC_ALL");
+ if (saved_LC_ALL)
+ saved_LC_ALL = strdup (saved_LC_ALL);
saved_LC_MESSAGES = setlocale (LC_MESSAGES, NULL);
@@ -339,6 +341,14 @@ translate_string (const char *string, const char *in_lang,
else
unsetenv ("LANG");
+ if (saved_LC_ALL)
+ {
+ setenv ("LC_ALL", saved_LC_ALL, 1);
+ free (saved_LC_ALL);
+ }
+ else
+ unsetenv ("LC_ALL");
+
if (saved_LC_MESSAGES)
{
setlocale (LC_MESSAGES, saved_LC_MESSAGES);