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