Hi,
On 2025/06/07 5:16, Timofei Zhakov wrote:
> Hi,
>
> I would like to suggest adding a line to svn --version command to display the
> current locale name.
>
> This could be helpful for us receiving or investigating any encoding-related
> bugs, and seems generally useful to a part of platform information.
>
> So, I decided to draft a patch (attached to the email) to implement this
> feature. Providing examples of the machine info section of the new svn
> --version --verbose command below:
>
> * running on x86_64-microsoft-windows6.2.9200
> - Windows 10 Pro, build 26100 [6.3 Client Multiprocessor Free]
> - locale encoding: CP1252
>
> ---
>
> * running on x86_64-unknown-linux-gnu
> - "Debian GNU/Linux 12 (bookworm)" [Linux 6.6.87.1-microsoft-standard-WSL2]
> - locale encoding: UTF-8
>
> ---
>
> * running on x86_64-unknown-linux-gnu
> - "Debian GNU/Linux 12 (bookworm)" [Linux 6.6.87.1-microsoft-standard-WSL2]
> - locale encoding: ISO-8859-15
>
> - I didn't yet find a good way to display this part: *en_US*.UTF-8 of locale
> info, but I think it's not mandatory for us. So it's fine.
I think we could retrieve the *.po headers from `dgettext()` which
passed an empty string and show the language of the message catalog by
extracting "Language: ..." from the headers.
See attached patch.
--
Jun Omae <jun6...@gmail.com> (大前 潤)
diff --git a/subversion/include/svn_version.h b/subversion/include/svn_version.h
index 392d26b39..f027f02ec 100644
--- a/subversion/include/svn_version.h
+++ b/subversion/include/svn_version.h
@@ -400,6 +400,16 @@ svn_version_ext_runtime_osname(const
svn_version_extended_t *ext_info);
const char *
svn_version_ext_character_encoding(const svn_version_extended_t *ext_info);
+/**
+ * Accessor for svn_version_extended_t.
+ *
+ * @return The language of the preferred message catalog.
+ *
+ * @since New in 1.15.
+ */
+const char *
+svn_version_ext_message_language(const svn_version_extended_t *ext_info);
+
/**
* Dependent library information.
* Describes the name and versions of known dependencies
diff --git a/subversion/libsvn_subr/opt_subcommand.c
b/subversion/libsvn_subr/opt_subcommand.c
index 84dc7f80f..7ce834158 100644
--- a/subversion/libsvn_subr/opt_subcommand.c
+++ b/subversion/libsvn_subr/opt_subcommand.c
@@ -493,6 +493,8 @@ svn_opt__print_version_info(const char *pgm_name,
SVN_ERR(svn_cmdline_printf(pool, _(" - character encoding: %s\n"),
svn_version_ext_character_encoding(info)));
+ SVN_ERR(svn_cmdline_printf(pool, _(" - message language: %s\n"),
+ svn_version_ext_message_language(info)));
libs = svn_version_ext_linked_libs(info);
if (libs && libs->nelts)
diff --git a/subversion/libsvn_subr/sysinfo.c b/subversion/libsvn_subr/sysinfo.c
index c8a63e44a..efc6e883d 100644
--- a/subversion/libsvn_subr/sysinfo.c
+++ b/subversion/libsvn_subr/sysinfo.c
@@ -144,6 +144,41 @@ svn_sysinfo__character_encoding(apr_pool_t *pool)
return apr_os_locale_encoding(pool);
}
+const char *
+svn_sysinfo__message_language(apr_pool_t *pool)
+{
+#ifdef ENABLE_NLS
+ const char *po_headers = dgettext(PACKAGE_NAME, "");
+ if (po_headers != NULL && po_headers[0] != '\0')
+ {
+ const char *p = po_headers;
+ while (*p)
+ {
+ const char *newline = strchr(p, '\n');
+ if (strncasecmp(p, "Language:", 9))
+ {
+ if (newline == NULL)
+ break;
+ p = newline + 1;
+ continue;
+ }
+ p += 9;
+ while (*p != '\n' && svn_ctype_isspace(*p))
+ p++;
+ if (newline == NULL)
+ return apr_pstrdup(pool, p);
+ else
+ return apr_pstrndup(pool, p, newline - p);
+ }
+ return apr_pstrdup(pool, _("(missing language header)"));
+ }
+ else
+ return "en";
+#else
+ return "(compiled without NLS supports)";
+#endif
+}
+
const apr_array_header_t *
svn_sysinfo__linked_libs(apr_pool_t *pool)
{
diff --git a/subversion/libsvn_subr/sysinfo.h b/subversion/libsvn_subr/sysinfo.h
index dc717885e..f3f85e37e 100644
--- a/subversion/libsvn_subr/sysinfo.h
+++ b/subversion/libsvn_subr/sysinfo.h
@@ -51,6 +51,12 @@ const char *svn_sysinfo__release_name(apr_pool_t *pool);
*/
const char *svn_sysinfo__character_encoding(apr_pool_t *pool);
+/* Return the language of the preferred message catalog.
+ *
+ * All allocations are done in POOL.
+ */
+const char *svn_sysinfo__message_language(apr_pool_t *pool);
+
/* Return an array of svn_version_linked_lib_t of descriptions of the
* link-time and run-time versions of dependent libraries, or NULL of
* the info is not available.
diff --git a/subversion/libsvn_subr/version.c b/subversion/libsvn_subr/version.c
index 0e9ffff32..eec0ff29e 100644
--- a/subversion/libsvn_subr/version.c
+++ b/subversion/libsvn_subr/version.c
@@ -123,6 +123,8 @@ struct svn_version_extended_t
const char *runtime_host; /* Runtime canonical host name */
const char *runtime_osname; /* Running OS release name */
const char *character_encoding; /* Encoding of the current locale */
+ const char *message_language; /* Language of the preferred message
+ catalog */
/* Array of svn_version_ext_linked_lib_t describing dependent
libraries. */
@@ -155,6 +157,7 @@ svn_version_extended(svn_boolean_t verbose,
info->runtime_host = svn_sysinfo__canonical_host(pool);
info->runtime_osname = svn_sysinfo__release_name(pool);
info->character_encoding = svn_sysinfo__character_encoding(pool);
+ info->message_language = svn_sysinfo__message_language(pool);
info->linked_libs = svn_sysinfo__linked_libs(pool);
info->loaded_libs = svn_sysinfo__loaded_libs(pool);
}
@@ -205,6 +208,12 @@ svn_version_ext_character_encoding(const
svn_version_extended_t *ext_info)
return ext_info->character_encoding;
}
+const char *
+svn_version_ext_message_language(const svn_version_extended_t *ext_info)
+{
+ return ext_info->message_language;
+}
+
const apr_array_header_t *
svn_version_ext_linked_libs(const svn_version_extended_t *ext_info)
{