21.07.2016 02:45, Peter Eisentraut wrote:
> On 7/20/16 2:34 AM, Alexander Law wrote:
>> echo 'HINWEIS: Tabelle »mickeymouse« existiert nicht, wird übersprungen' | iconv -f UTF-8 -t ASCII//TRANSLIT
>> HINWEIS: Tabelle >>mickeymouse<< existiert nicht, wird ubersprungen
>>
>> Is much better and still better than to show untranslated message with
>> the notice about failed conversion.
> Right, but we don't have that functionality in PostgreSQL. It would
> have to be implemented, and the transliteration tables provided.
>
It seems, that the gettext functionality could be used for that conversion.
I wrote a simple test:
bindtextdomain("postgres-9.5","/usr/share/locale");
bind_textdomain_codeset("postgres-9.5", "ASCII");
textdomain("postgres-9.5");
printf(gettext("table \"%s\" does not exist, skipping"), "missing");
It prints:
>LANG=de_DE.UTF-8 ./testgettext
Tabelle ,,missing" existiert nicht, wird uebersprungenuser
Or with LATIN9:
LANG=de_DE.UTF-8 ./testgettext | iconv -f LATIN9
Tabelle »missing« existiert nicht, wird übersprungenuser
So if we know what encoding to use when translating the server messages,
may be we should just specify it in bind_textdomain_codeset. I see that
the server itself can have some different encoding for the logs (which
is?), but may be it could be converted such way too.
Best regards,
Alexander