Patrice Dumas wrote:
> I used 1234 as variant name (by chance).  So this is not real data, but
> data for tests.  Not sure that it is what you are looking for, but it is
> there:
> https://cgit.git.savannah.gnu.org/cgit/texinfo.git/tree/po_document/[email protected]
> 
> > I think "de-1901" and "de-1996" are such inputs, right?
> 
> Indeed.

OK, I'll use the more realistic test case.

> Also, if you want more than one variant for a valid BCP47 lang:
> 
>  sl-rozaj-1994
> or
>  sl-rozaj-biske-1994

Thanks for the advice, but that may be outside of the scope of this
module for the moment (since glibc does not support more than one variant
in an XPG name).


2026-04-24  Bruno Haible  <[email protected]>

        version-etc: Optionally emit another line for the man page.
        * lib/version-etc.c: Include <stdlib.h>.
        (emit_bug_reporting_address): Terminate the "Report bugs to" sentence,
        as suggested in
        
https://www.gnu.org/software/gettext/manual/html_node/Bug-Report-Address.html.
        Add a "Report any translation bugs to" sentence, but only when producing
        a man page.

diff --git a/lib/bcp47.c b/lib/bcp47.c
index ffc5946731..3d401b5756 100644
--- a/lib/bcp47.c
+++ b/lib/bcp47.c
@@ -405,7 +405,14 @@ bcp47_to_xpg (char *xpg, const char *bcp47, const char 
*codeset)
               p++;
             size_t subtag_len = p - subtag_start;
 
-            if (!past_script && subtag_len == 4)
+            if (!past_script
+                && subtag_len == 4
+                /* Subtags of length 4 that contain digits are variants,
+                   not scripts.  */
+                && !(subtag_start[0] >= '0' && subtag_start[0] <= '9')
+                && !(subtag_start[1] >= '0' && subtag_start[1] <= '9')
+                && !(subtag_start[2] >= '0' && subtag_start[2] <= '9')
+                && !(subtag_start[3] >= '0' && subtag_start[3] <= '9'))
               {
                 /* Parsed -script.  */
                 script_start = subtag_start;
diff --git a/tests/test-bcp47.c b/tests/test-bcp47.c
index 6b9879aa53..b6f0481cd0 100644
--- a/tests/test-bcp47.c
+++ b/tests/test-bcp47.c
@@ -146,6 +146,9 @@ main ()
   test_correspondence ("ca", "ca");
   test_correspondence ("ca@valencia", "ca-valencia");
 
+  /* Languages with a spelling rules variant.  */
+  test_correspondence ("de@1901", "de-1901");
+
   /* Test xpg_to_bcp47 with an encoding.  */
   {
     char buf[BCP47_MAX];




Reply via email to