diff options
author | Yorhel <git@yorhel.nl> | 2013-01-21 13:07:33 +0100 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2013-01-21 13:07:33 +0100 |
commit | 6f5d0ae1bacab24e4ba9c854501930572f84d256 (patch) | |
tree | 9c72bb6ce3f527cd33a42eee45b4d9c2edc6e20d /lib | |
parent | d2659304b32097e64f012a28f9c26c434c84f9e3 (diff) |
I18N: Merge all translation strings that eval to "Unknown"
A generic '_unknown' is more easily usable.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/VNDB/Func.pm | 13 | ||||
-rw-r--r-- | lib/VNDB/Handler/Chars.pm | 6 | ||||
-rw-r--r-- | lib/VNDB/Handler/Releases.pm | 22 | ||||
-rw-r--r-- | lib/VNDB/Handler/ULists.pm | 10 | ||||
-rw-r--r-- | lib/VNDB/Handler/VNEdit.pm | 2 | ||||
-rw-r--r-- | lib/VNDB/Handler/VNPage.pm | 26 |
6 files changed, 45 insertions, 34 deletions
diff --git a/lib/VNDB/Func.pm b/lib/VNDB/Func.pm index 4f564a18..54acfe4f 100644 --- a/lib/VNDB/Func.pm +++ b/lib/VNDB/Func.pm @@ -10,6 +10,7 @@ use VNDBUtil; our @EXPORT = (@VNDBUtil::EXPORT, qw| clearfloat cssicon tagscore mt minage fil_parse fil_serialize parenttags childtags charspoil imgpath imgurl fmtvote + mtvoiced mtani mtvnlen mtrlstat mtvnlstat mtbloodt |); @@ -69,7 +70,7 @@ sub mt { sub minage { my($a, $ex) = @_; - my $str = $a == -1 ? mt '_minage_null' : !$a ? mt '_minage_all' : mt '_minage_age', $a; + my $str = $a == -1 ? mt '_unknown' : !$a ? mt '_minage_all' : mt '_minage_age', $a; $ex = !defined($a) ? '' : { 0 => 'CERO A', 12 => 'CERO B', @@ -200,5 +201,15 @@ sub fmtvote { return !$_[0] ? '-' : $_[0] % 10 == 0 ? $_[0]/10 : sprintf '%.1f', $_[0]/10; } + +# mt() wrappers for data-dependent translation strings that have a special +# value for 'unknown'. +sub mtvoiced { !$_[0] ? mt '_unknown' : mt '_voiced_'.$_[0]; } +sub mtani { !$_[0] ? mt '_unknown' : mt '_animated_'.$_[0]; } +sub mtvnlen { !$_[0] ? mt '_unknown' : mt '_vnlength_'.$_[0], $_[1]||0; } +sub mtrlstat { !$_[0] ? mt '_unknown' : mt '_rlist_status_'.$_[0]; } +sub mtvnlstat{ !$_[0] ? mt '_unknown' : mt '_vnlist_status_'.$_[0]; } +sub mtbloodt { $_[0] eq 'unknown' ? mt '_unknown' : mt '_bloodt_'.$_[0]; } + 1; diff --git a/lib/VNDB/Handler/Chars.pm b/lib/VNDB/Handler/Chars.pm index ed1ae733..4c32c7bd 100644 --- a/lib/VNDB/Handler/Chars.pm +++ b/lib/VNDB/Handler/Chars.pm @@ -46,7 +46,7 @@ sub page { [ s_hip => serialize => sub { $_[0]||mt '_revision_empty' } ], [ height => serialize => sub { $_[0]||mt '_revision_empty' } ], [ weight => serialize => sub { $_[0]||mt '_revision_empty' } ], - [ bloodt => serialize => sub { mt "_bloodt_$_[0]" } ], + [ bloodt => serialize => \&mtbloodt ], [ main => htmlize => sub { $_[0] ? sprintf '<a href="/c%d">c%d</a>', $_[0], $_[0] : mt '_revision_empty' } ], [ main_spoil=> serialize => sub { mt "_spoil_$_[0]" } ], [ image => htmlize => sub { @@ -123,7 +123,7 @@ sub charTable { } b class => 'grayedout', style => 'margin-right: 10px', $r->{original} if $r->{original}; cssicon "gen $r->{gender}", mt "_gender_$r->{gender}" if $r->{gender} ne 'unknown'; - span mt "_bloodt_$r->{bloodt}" if $r->{bloodt} ne 'unknown'; + span mtbloodt $r->{bloodt} if $r->{bloodt} ne 'unknown'; end; end; end; @@ -363,7 +363,7 @@ sub edit { [ input => name => mt('_chare_form_height'),short => 'height', width => 50, post => ' cm' ], [ input => name => mt('_chare_form_weight'),short => 'weight', width => 50, post => ' kg' ], [ select => name => mt('_chare_form_bloodt'),short => 'bloodt', options => [ - map [ $_, mt("_bloodt_$_") ], @{$self->{blood_types}} ] ], + map [ $_, mtbloodt $_ ], @{$self->{blood_types}} ] ], [ static => content => '<br />' ], [ input => name => mt('_chare_form_main'), short => 'main', width => 50, post => ' '.mt('_chare_form_main_note') ], [ select => name => mt('_chare_form_main_spoil'), short => 'main_spoil', options => [ diff --git a/lib/VNDB/Handler/Releases.pm b/lib/VNDB/Handler/Releases.pm index f0a0707e..f25423bd 100644 --- a/lib/VNDB/Handler/Releases.pm +++ b/lib/VNDB/Handler/Releases.pm @@ -58,9 +58,9 @@ sub page { map $self->{media}{$_->{medium}} ? $_->{qty}.' '.mt("_med_$_->{medium}", $_->{qty}) : mt("_med_$_->{medium}",1), @{$_[0]} } ], [ resolution => serialize => sub { my $r = $self->{resolutions}[$_[0]][0]; $r =~ /^_/ ? mt($r) : $r } ], - [ voiced => serialize => sub { mt '_voiced_'.$_[0] } ], - [ ani_story => serialize => sub { mt '_animated_'.$_[0] } ], - [ ani_ero => serialize => sub { mt '_animated_'.$_[0] } ], + [ voiced => serialize => \&mtvoiced ], + [ ani_story => serialize => \&mtani ], + [ ani_ero => serialize => \&mtani ], [ producers => join => '<br />', split => sub { map sprintf('<a href="/p%d" title="%s">%s</a> (%s)', $_->{id}, $_->{original}||$_->{name}, shorten($_->{name}, 50), join(', ', $_->{developer} ? mt '_reldiff_developer' :(), $_->{publisher} ? mt '_reldiff_publisher' :()) @@ -170,7 +170,7 @@ sub _infotable { if($r->{voiced}) { Tr; td mt '_relinfo_voiced'; - td mt '_voiced_'.$r->{voiced}; + td mtvoiced $r->{voiced}; end; } @@ -178,8 +178,8 @@ sub _infotable { Tr; td mt '_relinfo_ani'; td join ', ', - $r->{ani_story} ? mt('_relinfo_ani_story', mt '_animated_'.$r->{ani_story}):(), - $r->{ani_ero} ? mt('_relinfo_ani_ero', mt '_animated_'.$r->{ani_ero} ):(); + $r->{ani_story} ? mt('_relinfo_ani_story', mtani $r->{ani_story}):(), + $r->{ani_ero} ? mt('_relinfo_ani_ero', mtani $r->{ani_ero} ):(); end; } @@ -242,9 +242,9 @@ sub _infotable { td; Select id => 'listsel', name => $self->authGetCode("/r$r->{id}/list"); option value => -2, - mt !$rl ? '_relinfo_user_notlist' : ('_relinfo_user_inlist', mt('_rlist_status_'.$rl->{status})); + mt !$rl ? '_relinfo_user_notlist' : ('_relinfo_user_inlist', mtrlstat $rl->{status}); optgroup label => mt '_relinfo_user_setstatus'; - option value => $_, mt '_rlist_status_'.$_ + option value => $_, mtrlstat $_ for (@{$self->{rlist_status}}); end; option value => -1, mt '_relinfo_user_del' if $rl; @@ -410,11 +410,11 @@ sub _form { [ select => short => 'resolution', name => mt('_redit_form_resolution'), options => [ map [ $_, map /^_/?mt($_):$_, @{$self->{resolutions}[$_]} ], 0..$#{$self->{resolutions}} ] ], [ select => short => 'voiced', name => mt('_redit_form_voiced'), options => [ - map [ $_, mt '_voiced_'.$_ ], @{$self->{voiced}} ] ], + map [ $_, mtvoiced $_ ], @{$self->{voiced}} ] ], [ select => short => 'ani_story', name => mt('_redit_form_ani_story'), options => [ - map [ $_, mt '_animated_'.$_ ], @{$self->{animated}} ] ], + map [ $_, mtani $_ ], @{$self->{animated}} ] ], [ select => short => 'ani_ero', name => mt('_redit_form_ani_ero'), options => [ - map [ $_, $_ ? mt '_animated_'.$_ : mt('_redit_form_ani_ero_none') ], @{$self->{animated}} ] ], + map [ $_, $_ ? mtani $_ : mt('_redit_form_ani_ero_none') ], @{$self->{animated}} ] ], [ static => content => mt('_redit_form_ani_ero_note') ], [ hidden => short => 'media' ], [ static => nolabel => 1, content => sub { diff --git a/lib/VNDB/Handler/ULists.pm b/lib/VNDB/Handler/ULists.pm index 94e3a3fe..cdc30d01 100644 --- a/lib/VNDB/Handler/ULists.pm +++ b/lib/VNDB/Handler/ULists.pm @@ -405,7 +405,7 @@ sub vnlist { end; p class => 'browseopts'; a href => $url->(t => -1), -1 == $f->{t} ? (class => 'optselected') : (), mt '_rlist_all'; - a href => $url->(t => $_), $_ == $f->{t} ? (class => 'optselected') : (), mt '_vnlist_status_'.$_ for @{$self->{vnlist_status}}; + a href => $url->(t => $_), $_ == $f->{t} ? (class => 'optselected') : (), mtvnlstat $_ for @{$self->{vnlist_status}}; end; end 'div'; @@ -451,7 +451,7 @@ sub _vnlist_browse { a href => "/v$i->{vid}", title => $i->{original}||$i->{title}, shorten $i->{title}, 70; b class => 'grayedout', $i->{notes} if $i->{notes}; end; - td class => 'tc6', $i->{status} ? mt '_vnlist_status_'.$i->{status} : ''; + td class => 'tc6', $i->{status} ? mtvnlstat $i->{status} : ''; td class => 'tc7'; my $obtained = grep $_->{status}==2, @{$i->{rels}}; my $total = scalar @{$i->{rels}}; @@ -479,7 +479,7 @@ sub _vnlist_browse { td class => 'tc5'; a href => "/r$_->{rid}", title => $_->{original}||$_->{title}, shorten $_->{title}, 50; end; - td class => 'tc6', $_->{status} ? mt '_rlist_status_'.$_->{status} : ''; + td class => 'tc6', $_->{status} ? mtrlstat $_->{status} : ''; td class => 'tc7_8', colspan => 2, ''; end 'tr'; } @@ -493,7 +493,7 @@ sub _vnlist_browse { Select id => 'vns', name => 'vns'; option value => -2, mt '_rlist_withvn'; optgroup label => mt '_rlist_changestat'; - option value => $_, mt "_vnlist_status_$_" + option value => $_, mtvnlstat $_ for (@{$self->{vnlist_status}}); end; option value => 999, mt '_rlist_setnote'; @@ -502,7 +502,7 @@ sub _vnlist_browse { Select id => 'rel', name => 'rel'; option value => -2, mt '_rlist_withrel'; optgroup label => mt '_rlist_changestat'; - option value => $_, mt "_rlist_status_$_" + option value => $_, mtrlstat $_ for (@{$self->{rlist_status}}); end; option value => -1, mt '_rlist_del'; diff --git a/lib/VNDB/Handler/VNEdit.pm b/lib/VNDB/Handler/VNEdit.pm index d7cba196..fb64ae86 100644 --- a/lib/VNDB/Handler/VNEdit.pm +++ b/lib/VNDB/Handler/VNEdit.pm @@ -224,7 +224,7 @@ sub _form { [ textarea => short => 'desc', name => mt('_vnedit_desc').'<br /><b class="standout">'.mt('_inenglish').'</b>', rows => 10 ], [ static => content => mt '_vnedit_desc_msg' ], [ select => short => 'length', name => mt('_vnedit_length'), width => 450, options => - [ map [ $_ => mt '_vnlength_'.$_, 2 ], @{$self->{vn_lengths}} ] ], + [ map [ $_ => mtvnlen $_, 2 ], @{$self->{vn_lengths}} ] ], [ input => short => 'l_wp', name => mt('_vnedit_links'), pre => 'http://en.wikipedia.org/wiki/' ], [ input => short => 'l_encubed', pre => 'http://novelnews.net/tag/', post => '/' ], diff --git a/lib/VNDB/Handler/VNPage.pm b/lib/VNDB/Handler/VNPage.pm index 2fa3ef1e..a3dbe083 100644 --- a/lib/VNDB/Handler/VNPage.pm +++ b/lib/VNDB/Handler/VNPage.pm @@ -474,33 +474,33 @@ sub _write_release_string { cssicon "lang $_", mt "_lang_$_"; br if $_ ne $rel->{languages}[$#{$rel->{languages}}]; } - txt mt '_vnpage_release_unknown' if !@{$rel->{languages}}; + txt mt '_unknown' if !@{$rel->{languages}}; } when ('publication'){ txt mt $rel->{patch} ? '_relinfo_pub_patch' : '_relinfo_pub_nopatch', $rel->{freeware}?0:1, $rel->{doujin}?0:1 } when ('platforms') { for(@{$rel->{platforms}}) { cssicon $_, mt "_plat_$_"; br if $_ ne $rel->{platforms}[$#{$rel->{platforms}}]; } - txt mt '_vnpage_release_unknown' if !@{$rel->{platforms}}; + txt mt '_unknown' if !@{$rel->{platforms}}; } when ('media') { for (@{$rel->{media}}) { txt $self->{media}{$_->{medium}} ? $_->{qty}.' '.mt("_med_$_->{medium}", $_->{qty}) : mt("_med_$_->{medium}",1); br if $_ ne $rel->{media}[$#{$rel->{media}}]; } - txt mt '_vnpage_release_unknown' if !@{$rel->{media}}; + txt mt '_unknown' if !@{$rel->{media}}; } when ('resolution') { if($rel->{resolution}) { my $res = $self->{resolutions}[$rel->{resolution}][0]; txt $res =~ /^_/ ? mt $res : $res; } else { - txt mt '_vnpage_release_unknown'; + txt mt '_unknown'; } } - when ('voiced') { txt mt '_voiced_'.$rel->{voiced}; } + when ('voiced') { txt mtvoiced $rel->{voiced}; } when ('ani_ero') { txt join ', ', - $rel->{ani_story} ? mt('_relinfo_ani_story', mt '_animated_'.$rel->{ani_story}):(), - $rel->{ani_ero} ? mt('_relinfo_ani_ero', mt '_animated_'.$rel->{ani_ero} ):(); - txt mt '_vnpage_release_unknown' if !$rel->{ani_story} && !$rel->{ani_ero}; + $rel->{ani_story} ? mt('_relinfo_ani_story', mtani $rel->{ani_story}):(), + $rel->{ani_ero} ? mt('_relinfo_ani_ero', mtani $rel->{ani_ero} ):(); + txt mt '_unknown' if !$rel->{ani_story} && !$rel->{ani_ero}; } when ('released') { lit $self->{l10n}->datestr($rel->{released}) } when ('minage') { txt minage $rel->{minage} } @@ -579,7 +579,7 @@ sub page { if($v->{length}) { Tr; td mt '_vnpage_length'; - td mt '_vnlength_'.$v->{length}, 1; + td mtvnlen $v->{length}, 1; end; } my @links = ( @@ -685,7 +685,7 @@ sub _revision { [ original => diff => 1 ], [ alias => diff => qr/[ ,\n\.]/ ], [ desc => diff => qr/[ ,\n\.]/ ], - [ length => serialize => sub { mt '_vnlength_'.$_[0] } ], + [ length => serialize => \&mtvnlen ], [ l_wp => htmlize => sub { $_[0] ? sprintf '<a href="http://en.wikipedia.org/wiki/%s">%1$s</a>', xml_escape $_[0] : mt '_revision_nolink' }], @@ -854,9 +854,9 @@ sub _useroptions { } Select id => 'listsel', name => $self->authGetCode("/v$v->{id}/list"); - option $list ? mt '_vnpage_uopt_vnlisted', mt '_vnlist_status_'.$list->{status} : mt '_vnpage_uopt_novn'; + option $list ? mt '_vnpage_uopt_vnlisted', mtvnlstat $list->{status} : mt '_vnpage_uopt_novn'; optgroup label => $list ? mt '_vnpage_uopt_changevn' : mt '_vnpage_uopt_addvn'; - option value => $_, mt "_vnlist_status_$_" for (@{$self->{rlist_status}}); + option value => $_, mtrlstat $_ for (@{$self->{rlist_status}}); end; option value => -1, mt '_vnpage_uopt_delvn' if $list; end; @@ -961,7 +961,7 @@ sub _releases { td class => 'tc5'; if($self->authInfo->{id}) { a href => "/r$rel->{id}", id => "rlsel_$rel->{id}", class => 'vnrlsel', - $rel->{ulist} ? mt '_rlist_status_'.$rel->{ulist}{status} : '--'; + $rel->{ulist} ? mtrlstat $rel->{ulist}{status} : '--'; } else { txt ' '; } |