Show
Ignore:
Timestamp:
02/14/09 11:51:46 (5 years ago)
Author:
daisuke
Message:

mo locale fixes (still need to tweak)

Location:
lang/perl/DateTimeX-Lite/trunk
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/DateTimeX-Lite/trunk/lib/DateTimeX/Lite/Locale.pm

    r28645 r30032  
    8282 
    8383        no strict 'refs'; 
    84         *{$meth_name} = sub { $_[0]->{$field} }; 
    85     } 
     84        *{$meth_name} = sub { $_[0]->{$field} } } 
    8685} 
    8786 
     
    9291    # By making the default format lengths part of the object's hash 
    9392    # key, it allows them to be settable. 
    94     return bless { @_, 
     93    my $self = bless { @_, 
    9594        default_date_format_length => 'medium', 
    9695        default_time_format_length => 'medium', 
    9796    }, $class; 
     97 
     98    $self->{native_language} = $self->{en_language} 
     99        unless exists $self->{native_language}; 
     100     
     101    my @en_pieces; 
     102    my @native_pieces; 
     103    foreach my $p ( qw( language script territory variant ) ) 
     104    { 
     105        push @en_pieces, $self->{"en_$p"} if exists $self->{"en_$p"}; 
     106        push @native_pieces, $self->{"native_$p"} if exists $self->{"native_$p"}; 
     107    } 
     108 
     109    $self->{en_complete_name} = join ' ', @en_pieces; 
     110    $self->{native_complete_name} = join ' ', @native_pieces; 
     111 
     112    return $self; 
    98113} 
    99114 
  • lang/perl/DateTimeX-Lite/trunk/t/locale/01basic.t

    r27589 r30032  
    1313    $f =~ s/\.dat$//; 
    1414    $f 
    15 } sort <lib/DateTime/Lite/Locale/*.dat>; 
     15} sort <lib/DateTimeX/Lite/Locale/*.dat>; 
    1616# my %locale_names = map { $_ => 1 }  
    1717my %locale_ids   = map { $_ => 1 } @locale_ids; 
     
    6565        ok( $locale_ids{ $locale->id() }, "'$locale_id':  Has a valid locale id" ); 
    6666 
    67         TODO: { 
    68             local $TODO = "unimplemented"; 
    6967        ok( length $locale->name(), "'$locale_id':  Has a locale name" ); 
    7068        ok( length $locale->native_name(), 
    7169            "'$locale_id':  Has a native locale name" ); 
    72         } 
    7370 
    7471        # Each iteration runs one test if DateTime.pm is not available or 
     
    474471    for my $k ( sort keys %tests ) 
    475472    { 
     473        TODO: { 
    476474        my $desc = "$k for " . $locale->id(); 
     475 
     476        if ($k eq 'name' || $k eq 'language') { 
     477            todo_skip("$k unimplemented", 1); 
     478        } 
     479 
    477480        if ( ref $tests{$k} ) 
    478481        { 
     
    483486            is( $locale->$k(), $tests{$k}, $desc ); 
    484487        } 
     488        } 
    485489    } 
    486490} 
     
    494498    { 
    495499        is( $locale->format_for($name), $formats{$name}, 
    496             "Format for $name with " . $locale->id() ); 
     500            "Format for $name with " . $locale->id() ) or 
     501note( "got -> " . $locale->format_for($name) . ", expected: $formats{$name}"); 
    497502    } 
    498503 
  • lang/perl/DateTimeX-Lite/trunk/tools/lib/DateTimeX/Lite/Tool/Locale/Generator.pm

    r28646 r30032  
    22 
    33package DateTimeX::Lite::Tool::Locale::Generator; 
     4use utf8; 
    45use Moose; 
    56use Moose::Util::TypeConstraints; 
     
    134135    my $fh = $dat_file->openw() 
    135136        or die "Cannot write to $dat_file: $!"; 
    136     $fh->binmode(':utf8'); 
     137    $fh->binmode(':raw'); 
    137138 
    138139    print $fh <<EOF or die "could not write to $dat_file: $!"; 
     
    150151# 
    151152########################################################################### 
     153use utf8; 
    152154EOF 
    153155 
    154156    my $data = $self->generate_data($ldml->id); 
    155157 
    156     print $fh Dumper($data); 
     158    local $Data::Dumper::Sortkeys = 1; 
     159    local $Data::Dumper::Indent = 1; 
     160    print $fh Data::Dumper::Dumper($data); 
    157161    close($fh); 
    158162} 
     
    213217    } 
    214218 
    215     foreach my $k qw( 
    216 en_language 
    217 en_script 
    218 en_territory 
    219 en_variant 
    220 native_language 
    221 native_script 
    222 native_territory 
    223 native_variant 
    224     ) { 
     219    foreach my $k qw( en_language en_script en_territory en_variant native_language native_script native_territory native_variant) { 
    225220        my $v = $ldml->$k(); 
    226221        if (defined $v) { 
  • lang/perl/DateTimeX-Lite/trunk/tools/lib/DateTimeX/Lite/Tool/Locale/LDML.pm

    r27589 r30032  
    350350                  { 
    351351                      my $native_val = $ldml->_find_one_node_text($path); 
    352  
    353352                      return $native_val if defined $native_val; 
    354353                  } 
     
    407406        my $class = shift; 
    408407        my $file  = shift; 
     408 
     409print "Parseing $file\n===\n"; 
    409410 
    410411        my $doc = $Parser->parse_file( $file->stringify() );