@@ -6,29 +6,50 @@ CREATE FUNCTION test_translation()
66 RETURNS void
77 AS :'regresslib'
88 LANGUAGE C;
9- -- We don't want to assume that the platform has any particular language
10- -- installed, so we use a "translation" for the C locale. However, gettext
11- -- will short-circuit translation if lc_messages is just 'C'. Fake it out
12- -- by appending a codeset name. Fortunately it seems that that need not
13- -- match the actual database encoding.
14- SET lc_messages = 'C.UTF-8';
9+ -- There's less standardization in locale name spellings than one could wish.
10+ -- While some platforms insist on having a codeset name in lc_messages,
11+ -- fortunately it seems that it need not match the actual database encoding.
12+ -- However, if no es_ES locale is installed at all, this'll fail.
13+ SET lc_messages = 'C';
14+ do $$
15+ declare locale text; ok bool;
16+ begin
17+ for locale in values('es_ES'), ('es_ES.UTF-8'), ('es_ES.utf8')
18+ loop
19+ ok = true;
20+ begin
21+ execute format('set lc_messages = %L', locale);
22+ exception when invalid_parameter_value then
23+ ok = false;
24+ end;
25+ exit when ok;
26+ end loop;
27+ -- Don't clutter the expected results with this info, just log it
28+ raise log 'NLS regression test: lc_messages = %',
29+ current_setting('lc_messages');
30+ end $$;
31+ SELECT current_setting('lc_messages') = 'C' AS failed \gset
32+ \if :failed
33+ \echo Could not find an acceptable spelling of es_ES locale
34+ \quit
35+ \endif
1536SELECT test_translation();
16- NOTICE: translated PRId64 = 424242424242
17- NOTICE: translated PRId32 = -1234
18- NOTICE: translated PRIdMAX = -123456789012
19- NOTICE: translated PRIdPTR = - 9999
20- NOTICE: translated PRIu64 = 424242424242
21- NOTICE: translated PRIu32 = 4294966062
22- NOTICE: translated PRIuMAX = 123456789012
23- NOTICE: translated PRIuPTR = 9999
24- NOTICE: translated PRIx64 = 62c6d1a9b2
25- NOTICE: translated PRIx32 = fffffb2e
26- NOTICE: translated PRIxMAX = 1cbe991a14
27- NOTICE: translated PRIxPTR = 270f
28- NOTICE: translated PRIX64 = 62C6D1A9B2
29- NOTICE: translated PRIX32 = FFFFFB2E
30- NOTICE: translated PRIXMAX = 1CBE991A14
31- NOTICE: translated PRIXPTR = 270F
37+ NOTICE: traducido PRId64 = 424242424242
38+ NOTICE: traducido PRId32 = -1234
39+ NOTICE: traducido PRIdMAX = -5678
40+ NOTICE: traducido PRIdPTR = 9999
41+ NOTICE: traducido PRIu64 = 424242424242
42+ NOTICE: traducido PRIu32 = 1234
43+ NOTICE: traducido PRIuMAX = 5678
44+ NOTICE: traducido PRIuPTR = 9999
45+ NOTICE: traducido PRIx64 = 62c6d1a9b2
46+ NOTICE: traducido PRIx32 = 4d2
47+ NOTICE: traducido PRIxMAX = 162e
48+ NOTICE: traducido PRIxPTR = 270f
49+ NOTICE: traducido PRIX64 = 62C6D1A9B2
50+ NOTICE: traducido PRIX32 = 4D2
51+ NOTICE: traducido PRIXMAX = 162E
52+ NOTICE: traducido PRIXPTR = 270F
3253 test_translation
3354------------------
3455
0 commit comments