I was wondering if I could make visible the chosen locale. I do (on windows),
>bin\initdb --locale=en-us --encoding=utf-8 -U postgres -W clus1
>bin\pg_ctl.exe -D clus1 -l logfile2 start
>psql -U postgres
postgres=# select now();
now
-------------------------------
2022-03-07 21:15:07.56299 01
>bin\pg_ctl.exe -D clus1 -l logfile2 stop
>rmdir /s clus1
Now I choose another locale,
>bin\initdb --locale=nl-nl --encoding=utf-8 -U postgres -W clus1
>bin\pg_ctl.exe -D clus1 -l logfile2 start
>psql -U postgres
postgres=# select now();
now
-------------------------------
2022-03-07 21:16:30.071371 01
I thought now() would be in Dutch, but is isn't. Why not, and how can I make the locale visible, so check the chosen locale?
CodePudding user response:
The locale consists of several parts:
lc_collate: the rules to compare and sort stringslc_ctype: the rules to determine what type a character is (letter, digit, space, ...)lc_messages: the language for error and log messageslc_monetary: the language to use for currency format codes into_charfor numbersTo see the effect of
lc_monetary, trySELECT to_char(100, '999L');lc_numeric: the language to use for decimal comma and group separator format codes into_charfor numbersTo see the effect of
lc_numeric, trySELECT to_char(1000000.50, '9G999G999D00L');lc_time: the language to use for week day and month name format codes into_charfor timestamps,log_filenameand suchTo see the effect of
lc_numeric, trySELECT to_char(current_timestamp, 'FMDAY, DD. FMMONTH');
You can find the setting of each of them with SHOW:
SHOW lc_collate;
The type output functions for date/time and numeric data types don't use the locale settings, so the output of now() not affected by the locale.
