| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Acme::MetaSyntactic::Locale; | 
| 2 | 9 |  |  | 9 |  | 101370 | use strict; | 
|  | 9 |  |  |  |  | 37 |  | 
|  | 9 |  |  |  |  | 268 |  | 
| 3 | 9 |  |  | 9 |  | 46 | use warnings; | 
|  | 9 |  |  |  |  | 18 |  | 
|  | 9 |  |  |  |  | 222 |  | 
| 4 | 9 |  |  | 9 |  | 550 | use Acme::MetaSyntactic (); # do not export metaname and friends | 
|  | 9 |  |  |  |  | 19 |  | 
|  | 9 |  |  |  |  | 162 |  | 
| 5 | 9 |  |  | 9 |  | 2454 | use Acme::MetaSyntactic::MultiList; | 
|  | 9 |  |  |  |  | 25 |  | 
|  | 9 |  |  |  |  | 239 |  | 
| 6 | 9 |  |  | 9 |  | 47 | use List::Util qw( shuffle ); | 
|  | 9 |  |  |  |  | 15 |  | 
|  | 9 |  |  |  |  | 430 |  | 
| 7 | 9 |  |  | 9 |  | 54 | use Carp; | 
|  | 9 |  |  |  |  | 21 |  | 
|  | 9 |  |  |  |  | 749 |  | 
| 8 |  |  |  |  |  |  |  | 
| 9 |  |  |  |  |  |  | our @ISA = qw( Acme::MetaSyntactic::MultiList ); | 
| 10 |  |  |  |  |  |  | our $VERSION = '1.000'; | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  | sub init { | 
| 13 |  |  |  |  |  |  | # alias the older package variable %Locale to %MultiList | 
| 14 | 9 |  |  | 9 |  | 55 | no strict 'refs'; | 
|  | 9 |  |  |  |  | 17 |  | 
|  | 9 |  |  |  |  | 885 |  | 
| 15 | 8 |  |  | 8 | 1 | 1202 | *{"$_[0]::Locale"}    = \%{"$_[0]::MultiList"}; | 
|  | 8 |  |  |  |  | 36 |  | 
|  | 8 |  |  |  |  | 45 |  | 
| 16 | 8 |  |  |  |  | 19 | ${"$_[0]::Separator"} = '_'; | 
|  | 8 |  |  |  |  | 39 |  | 
| 17 |  |  |  |  |  |  |  | 
| 18 |  |  |  |  |  |  | # call the parent class init code | 
| 19 | 8 |  |  |  |  | 67 | goto &Acme::MetaSyntactic::MultiList::init; | 
| 20 |  |  |  |  |  |  | } | 
| 21 |  |  |  |  |  |  |  | 
| 22 |  |  |  |  |  |  | sub new { | 
| 23 | 56 |  |  | 56 | 1 | 586389 | my $class = shift; | 
| 24 |  |  |  |  |  |  |  | 
| 25 | 9 |  |  | 9 |  | 51 | no strict 'refs'; | 
|  | 9 |  |  |  |  | 17 |  | 
|  | 9 |  |  |  |  | 2234 |  | 
| 26 | 56 |  |  |  |  | 162 | my $self = bless { @_, cache => [] }, $class; | 
| 27 |  |  |  |  |  |  |  | 
| 28 |  |  |  |  |  |  | # compute some defaults | 
| 29 | 56 | 100 |  |  |  | 224 | if( ! exists $self->{category} ) { | 
| 30 |  |  |  |  |  |  | $self->{category} = | 
| 31 |  |  |  |  |  |  | exists $self->{lang} | 
| 32 |  |  |  |  |  |  | ? $self->{lang} | 
| 33 | 54 | 100 | 100 |  |  | 265 | : $ENV{LANGUAGE} || $ENV{LANG} || ''; | 
| 34 | 54 | 100 | 100 |  |  | 196 | if( !$self->{category} && $^O eq 'MSWin32' ) { | 
| 35 | 2 |  |  |  |  | 4 | eval { require Win32::Locale; }; | 
|  | 2 |  |  |  |  | 13 |  | 
| 36 | 2 | 50 |  |  |  | 9 | $self->{category} = Win32::Locale::get_language() unless $@; | 
| 37 |  |  |  |  |  |  | } | 
| 38 |  |  |  |  |  |  | } | 
| 39 |  |  |  |  |  |  |  | 
| 40 | 56 |  |  |  |  | 92 | my $cat = $self->{category}; | 
| 41 |  |  |  |  |  |  |  | 
| 42 |  |  |  |  |  |  | # support for territories | 
| 43 | 56 | 100 | 100 |  |  | 163 | if ( $cat && $cat ne ':all' ) { | 
| 44 | 30 |  |  |  |  | 131 | ($cat) = $cat =~ /^([-A-Za-z_]+)/; | 
| 45 | 30 |  | 50 |  |  | 79 | $cat = lc( $cat || '' ); | 
| 46 |  |  |  |  |  |  | 1 while $cat | 
| 47 | 30 |  | 100 |  |  | 67 | && !exists ${"$class\::MultiList"}{$cat} | 
|  | 33 |  | 66 |  |  | 175 |  | 
| 48 |  |  |  |  |  |  | && $cat =~ s/_?[^_]*$//; | 
| 49 |  |  |  |  |  |  | } | 
| 50 |  |  |  |  |  |  |  | 
| 51 |  |  |  |  |  |  | # fall back to last resort | 
| 52 | 56 |  | 66 |  |  | 133 | $self->{category} = $cat || ${"$class\::Default"}; | 
| 53 | 56 |  |  |  |  | 191 | $self->_compute_base(); | 
| 54 | 56 |  |  |  |  | 148 | return $self; | 
| 55 |  |  |  |  |  |  | } | 
| 56 |  |  |  |  |  |  |  | 
| 57 |  |  |  |  |  |  | *lang      = \&Acme::MetaSyntactic::MultiList::category; | 
| 58 |  |  |  |  |  |  | *languages = \&Acme::MetaSyntactic::MultiList::categories; | 
| 59 |  |  |  |  |  |  |  | 
| 60 |  |  |  |  |  |  | 1; | 
| 61 |  |  |  |  |  |  |  | 
| 62 |  |  |  |  |  |  | __END__ |