$Class{$id} = $p{class} if defined exists $p{class};
}
sub registered_id
{
shift;
my ($id) = validate_pos( @_, { type => SCALAR } );
return 1 if $AliasToID{$id};
return 1 if $DataForID{$id};
return 0;
}
sub add_aliases
{
shift;
%LoadCache = ();
my $aliases = ref $_[0] ? $_[0] : {@_};
while ( my ( $alias, $id ) = each %$aliases )
{
die "Unregistered locale '$id' cannot be used as an alias target for $alias"
unless __PACKAGE__->registered_id($id);
die "Can't alias an id to itself"
if $alias eq $id;
# check for overwrite?
my %seen = ( $alias => 1, $id => 1 );
my $copy = $id;
while ( $copy = $AliasToID{$copy} )
{
die "Creating an alias from $alias to $id would create a loop.\n"
if $seen{$copy};
$seen{$copy} = 1;
}
$AliasToID{$alias} = $id;
}
}
sub remove_alias
{
shift;
%LoadCache = ();
my ($alias) = validate_pos( @_, { type => SCALAR } );
return delete $AliasToID{$alias};
}
BEGIN
{
__PACKAGE__->register( @DateTime::Locale::Locales );
__PACKAGE__->add_aliases( \%DateTime::Locale::Aliases );
}
sub ids { wantarray ? keys %DataForID : [ keys %DataForID ] }
sub names { wantarray ? keys %NameToID : [ keys %NameToID ] }
sub native_names { wantarray ? keys %NativeNameToID : [ keys %NativeNameToID ] }
# These are hardcoded for backwards comaptibility with the
# DateTime::Language code.
my %OldAliases =
( 'Afar' => 'aa',
'Amharic' => 'am_ET',
'Austrian' => 'de_AT',
'Brazilian' => 'pt_BR',
'Czech' => 'cs_CZ',
'Danish' => 'da_DK',
'Dutch' => 'nl_NL',
'English' => 'en_US',
'French' => 'fr_FR',
# 'Gedeo' => undef, # XXX
'German' => 'de_DE',
'Italian' => 'it_IT',
'Norwegian' => 'no_NO',
'Oromo' => 'om_ET', # Maybe om_KE or plain om ?
'Portugese' => 'pt_PT',
'Sidama' => 'sid',
'Somali' => 'so_SO',
'Spanish' => 'es_ES',
'Swedish' => 'sv_SE',
'Tigre' => 'tig',
'TigrinyaEthiopian' => 'ti_ET',
'TigrinyaEritrean' => 'ti_ER',
);
sub load
{
my $class = shift;
my ($name) = validate_pos( @_, { type => SCALAR } );
=2= |