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