[solved] Help: Perl and setlocale()

My script is written in Perl and I started translating messages into German. French, … will follow soon.

I use


use POSIX;

use utf8;
binmode STDIN,  ":utf8";
binmode STDOUT, ":utf8";
binmode STDERR, ":utf8";

use locale;
use Locale::gettext;
use Locale::Util    qw ( set_locale );

and translate with “gettext()”

For ‘German’ (de_DE) I get the messages from …/locale/de/LC_MESSAGES/ptna.mo, so far so good.

I managed to make it work on my OpenSuse Linux (with tons of ‘locale -a’) and it now shows ü,Ü, ä, Ä, … correctly.

However, on a Debian with less “locale -a” it finds the message catalog but spoils the ü, Ü, …
Can’t make it work.

Debian-$ locale -a
C
C.UTF-8
de_DE.utf8
en_US.utf8
POSIX
ru_RU.utf8

Here’s the other part of the code


    $ENV{'LANG'} = 'de_DE';
    $ENV{'LANGUAGE'} = $ENV{'LANG'};
    setlocale( LC_ALL, '' );
    bindtextdomain( 'ptna', $PATH );
    textdomain( "ptna" );

I also tried “de_DE.UTF-8” and ‘de_DE.utf8’ and setlocale(LC_ALL,‘de’,‘DE’) also set_locale(), … but it still spoils the ü, Ü, …

Access to Debian is via “ssh” though - does this make the difference.

I’m lost now - any help?

Toni

Seems that the following is sufficient to find the message catalog …


    $ENV{'LANGUAGE'} = 'de';
    setlocale( LC_MESSAGES, '' );
    bindtextdomain( 'ptna', $PATH );
    textdomain( "ptna" );

Seems that the following does the magic by decoding the text from the message catalog (UTF-8) into Perl’s internal character representation


    printf decode( 'utf8', gettext( "..." ) );

… at least it works now as expected.