1#!/usr/bin/perl -Tw 2 3use strict; 4use Test::More tests => 10; 5 6BEGIN { 7 use_ok( 'Locale::Maketext' ); 8} 9 10print "# --- Making sure that get_handle works ---\n"; 11 12# declare some classes... 13{ 14 package Woozle; 15 our @ISA = ('Locale::Maketext'); 16 sub dubbil { return $_[1] * 2 } 17 sub numerate { return $_[2] . 'en' } 18} 19{ 20 package Woozle::eu_mt; 21 our @ISA = ('Woozle'); 22 our %Lexicon = ( 23 'd2' => 'hum [dubbil,_1]', 24 'd3' => 'hoo [quant,_1,zaz]', 25 'd4' => 'hoo [*,_1,zaz]', 26 ); 27 keys %Lexicon; # dodges the 'used only once' warning 28} 29 30my $lh = Woozle->get_handle('eu-mt'); 31isa_ok( $lh, 'Woozle::eu_mt' ); 32is( $lh->maketext( 'd2', 7 ), 'hum 14' ); 33 34print "# Make sure we can assign to ENV entries\n", 35"# (Otherwise we can't run the subsequent tests)...\n"; 36$ENV{'MYORP'} = 'Zing'; 37is( $ENV{'MYORP'}, 'Zing' ); 38$ENV{'SWUZ'} = 'KLORTHO HOOBOY'; 39is( $ENV{'SWUZ'}, 'KLORTHO HOOBOY' ); 40 41delete $ENV{'MYORP'}; 42delete $ENV{'SWUZ'}; 43 44 45print "# Test LANG...\n"; 46$ENV{'LC_ALL'} = ''; 47$ENV{'LC_MESSAGES'} = ''; 48$ENV{'REQUEST_METHOD'} = ''; 49$ENV{'LANG'} = 'Eu_MT'; 50$ENV{'LANGUAGE'} = ''; 51$lh = Woozle->get_handle(); 52isa_ok( $lh, 'Woozle::eu_mt' ); 53 54print "# Test LANGUAGE...\n"; 55$ENV{'LANG'} = ''; 56$ENV{'LANGUAGE'} = 'Eu-MT'; 57$lh = Woozle->get_handle(); 58isa_ok( $lh, 'Woozle::eu_mt' ); 59 60print "# Test HTTP_ACCEPT_LANGUAGE...\n"; 61$ENV{'REQUEST_METHOD'} = 'GET'; 62$ENV{'HTTP_ACCEPT_LANGUAGE'} = 'eu-MT'; 63$lh = Woozle->get_handle(); 64isa_ok( $lh, 'Woozle::eu_mt' ); 65 66$ENV{'HTTP_ACCEPT_LANGUAGE'} = 'x-plorp, zaz, eu-MT, i-klung'; 67$lh = Woozle->get_handle(); 68isa_ok( $lh, 'Woozle::eu_mt' ); 69 70$ENV{'HTTP_ACCEPT_LANGUAGE'} = 'x-plorp, zaz, eU-Mt, i-klung'; 71$lh = Woozle->get_handle(); 72isa_ok( $lh, 'Woozle::eu_mt' ); 73