Re: L10n in Gtk2-perl with Locale::Maketext::Lexicon

I just wrote the following example of how to do localization of a
Gtk2-perl program and thought it might be useful for others. Perhaps
we should put it somewhere in the wiki:

Although Locale::Maketest is a nice system, and much easier to use in
Perl, l in my experience it's better to use GNU gettext for l10n. Using
gettext means that auto-generated strings like those from Glade get
automagically generated.


        use POSIX qw(setlocale);
        use Locale::gettext;
        # name of your program:
        my $APP_NAME = 'foobar';
        # get language from environment:
        my $LANGUAGE = $ENV{LANG} || 'en_US';
        # put your .mo files in /usr/share/locale/$APP_NAME/LC_MESSAGES:
        my $DIRECTORY = '/usr/share/locale';
        setlocale(LC_ALL, $LANGUAGE);
        bindtextdomain($APP_NAME, $DIRECTORY);

        print gettext('Hello World!');


Gavin Brown
e: gavin brown uk com

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]