Next Tricks of the Wizards 91

Internationalization

        package Translate;
        use Filter::Simple;
        my %lexicon =
        ( 'Hello there!\n' => "¡Buenos Dias!\n",
          'Should I erase all your files (yes/no)?  '
                => '¿Debo borrar todos sus archivos (si/no)?  '
          'yes' => 'si',
        );
        FILTER_ONLY string => sub {
          unless (exists $lexicon{$_}) {
            warn qq{No translation for "$_"\n};
            $lexicon{$_} = $_;
          }
          $_ = $lexicon{$_};
        };


Next Copyright © 2003 M. J. Dominus