summaryrefslogtreecommitdiff
path: root/lib/VNDB/Handler
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2016-01-16 11:52:22 +0100
committerYorhel <git@yorhel.nl>2016-01-16 15:11:36 +0100
commit6313653b01652affded23d682d136e5e6ee42799 (patch)
tree528263a90a2c336c3ab6226c211a1abeccffacb3 /lib/VNDB/Handler
parentca1a9c48c24a436babd30ad9e315db2781364879 (diff)
L10N: Intern languages/platforms/resolutions/media/ptype/rtype/vnlength
Diffstat (limited to 'lib/VNDB/Handler')
-rw-r--r--lib/VNDB/Handler/Misc.pm29
-rw-r--r--lib/VNDB/Handler/Producers.pm27
-rw-r--r--lib/VNDB/Handler/Releases.pm57
-rw-r--r--lib/VNDB/Handler/Staff.pm10
-rw-r--r--lib/VNDB/Handler/ULists.pm4
-rw-r--r--lib/VNDB/Handler/VNBrowse.pm4
-rw-r--r--lib/VNDB/Handler/VNEdit.pm4
-rw-r--r--lib/VNDB/Handler/VNPage.pm46
8 files changed, 78 insertions, 103 deletions
diff --git a/lib/VNDB/Handler/Misc.pm b/lib/VNDB/Handler/Misc.pm
index cb9a508a..e36c0254 100644
--- a/lib/VNDB/Handler/Misc.pm
+++ b/lib/VNDB/Handler/Misc.pm
@@ -13,7 +13,6 @@ TUWF::register(
qr{}, \&homepage,
qr{(?:([upvrcs])([1-9]\d*)/)?hist},\&history,
qr{d([1-9]\d*)}, \&docpage,
- qr{setlang}, \&setlang,
qr{nospam}, \&nospam,
qr{xml/prefs\.xml}, \&prefs,
qr{opensearch\.xml}, \&opensearch,
@@ -150,8 +149,8 @@ sub homepage {
li;
lit $self->{l10n}->datestr($_->{released});
txt ' ';
- cssicon $_, mt "_plat_$_" for (@{$_->{platforms}});
- cssicon "lang $_", mt "_lang_$_" for (@{$_->{languages}});
+ cssicon $_, $self->{platforms}{$_} for (@{$_->{platforms}});
+ cssicon "lang $_", $self->{languages}{$_} for (@{$_->{languages}});
txt ' ';
a href => "/r$_->{id}", title => $_->{original}||$_->{title}, shorten $_->{title}, 30;
end;
@@ -170,8 +169,8 @@ sub homepage {
li;
lit $self->{l10n}->datestr($_->{released});
txt ' ';
- cssicon $_, mt "_plat_$_" for (@{$_->{platforms}});
- cssicon "lang $_", mt "_lang_$_" for (@{$_->{languages}});
+ cssicon $_, $self->{platforms}{$_} for (@{$_->{platforms}});
+ cssicon "lang $_", $self->{languages} for (@{$_->{languages}});
txt ' ';
a href => "/r$_->{id}", title => $_->{original}||$_->{title}, shorten $_->{title}, 30;
end;
@@ -346,26 +345,6 @@ sub docpage {
}
-sub setlang {
- my $self = shift;
-
- my $frm = $self->formValidate(
- {get => 'lang', required => 1, enum => [ VNDB::L10N::languages ]},
- {get => 'ref', required => 0, default => '/'}
- );
- return $self->resNotFound if $frm->{_err};
-
- my $browser = VNDB::L10N->get_handle()->language_tag();
-
- $self->resRedirect($frm->{ref}, 'post');
- if($frm->{lang} ne $self->{l10n}->language_tag()) {
- $self->authInfo->{id}
- ? $self->authPref(l10n => $frm->{lang} eq $browser ? undef : $frm->{lang})
- : $self->resCookie(l10n => $frm->{lang} eq $browser ? undef : $frm->{lang}, expires => time()+31536000);
- }
-}
-
-
sub nospam {
my $self = shift;
$self->htmlHeader(title => mt '_nospam_title', noindex => 1);
diff --git a/lib/VNDB/Handler/Producers.pm b/lib/VNDB/Handler/Producers.pm
index 69000b27..cf534b3e 100644
--- a/lib/VNDB/Handler/Producers.pm
+++ b/lib/VNDB/Handler/Producers.pm
@@ -27,9 +27,10 @@ sub rg {
return if $self->htmlRGHeader($title, 'p', $p);
$p->{svg} =~ s/id="node_p$pid"/id="graph_current"/;
+ # TODO: These strings can be properly interned in the SVG now
$p->{svg} =~ s/\$___(_prodrel_[a-z]+)____\$/mt $1/eg;
- $p->{svg} =~ s/\$(_lang_[a-z]+)_\$/mt $1/eg;
- $p->{svg} =~ s/\$(_ptype_[a-z]+)_\$/mt $1/eg;
+ $p->{svg} =~ s/\$_lang_([a-z-]+)_\$/$self->{languages}{$1}/eg;
+ $p->{svg} =~ s/\$_ptype_([a-z]+)_\$/$self->{producer_types}{$1}/eg;
div class => 'mainbox';
h1 $title;
@@ -59,11 +60,11 @@ sub page {
if($rev) {
my $prev = $rev && $rev > 1 && $self->dbProducerGetRev(id => $pid, rev => $rev-1, what => 'extended relations')->[0];
$self->htmlRevision('p', $prev, $p,
- [ type => serialize => sub { mt "_ptype_$_[0]" } ],
+ [ type => serialize => sub { $self->{producer_types}{$_[0]} } ],
[ name => diff => 1 ],
[ original => diff => 1 ],
[ alias => diff => qr/[ ,\n\.]/ ],
- [ lang => serialize => sub { "$_[0] (".mt("_lang_$_[0]").')' } ],
+ [ lang => serialize => sub { "$_[0] ($self->{languages}{$_[0]})" } ],
[ website => diff => 1 ],
[ l_wp => htmlize => sub {
$_[0] ? sprintf '<a href="http://en.wikipedia.org/wiki/%s">%1$s</a>', xml_escape $_[0] : mt '_revision_nolink'
@@ -83,7 +84,7 @@ sub page {
h1 $p->{name};
h2 class => 'alttitle', $p->{original} if $p->{original};
p class => 'center';
- txt mt '_prodpage_langtype', mt("_lang_$p->{lang}"), mt "_ptype_$p->{type}";
+ txt mt '_prodpage_langtype', $self->{languages}{$p->{lang}}, $self->{producer_types}{$p->{type}};
lit '<br />'.html_escape mt '_prodpage_aliases', $p->{alias} if $p->{alias};
my @links = (
@@ -168,10 +169,10 @@ sub _releases {
td class => 'tc3';
for (sort @{$rel->{platforms}}) {
next if $_ eq 'oth';
- cssicon $_, mt "_plat_$_";
+ cssicon $_, $self->{platforms}{$_};
}
- cssicon "lang $_", mt "_lang_$_" for (@{$rel->{languages}});
- cssicon "rt$rel->{type}", mt "_rtype_$rel->{type}";
+ cssicon "lang $_", $self->{languages}{$_} for (@{$rel->{languages}});
+ cssicon "rt$rel->{type}", $rel->{type};
end;
td class => 'tc4';
a href => "/r$rel->{id}", title => $rel->{original}||$rel->{title}, $rel->{title};
@@ -218,11 +219,11 @@ sub edit {
if($self->reqMethod eq 'POST') {
return if !$self->authCheckCode;
$frm = $self->formValidate(
- { post => 'type', enum => $self->{producer_types} },
+ { post => 'type', enum => [ keys %{$self->{producer_types}} ] },
{ post => 'name', maxlength => 200 },
{ post => 'original', required => 0, maxlength => 200, default => '' },
{ post => 'alias', required => 0, maxlength => 500, default => '' },
- { post => 'lang', enum => $self->{languages} },
+ { post => 'lang', enum => [ keys %{$self->{languages}} ] },
{ post => 'website', required => 0, maxlength => 250, default => '', template => 'weburl' },
{ post => 'l_wp', required => 0, maxlength => 150, default => '' },
{ post => 'desc', required => 0, maxlength => 5000, default => '' },
@@ -271,14 +272,14 @@ sub edit {
$self->htmlForm({ frm => $frm, action => $pid ? "/p$pid/edit" : '/p/new', editsum => 1 },
'pedit_geninfo' => [ mt('_pedit_form_generalinfo'),
[ select => name => mt('_pedit_form_type'), short => 'type',
- options => [ map [ $_, mt "_ptype_$_" ], sort @{$self->{producer_types}} ] ],
+ options => [ map [ $_, $self->{producer_types}{$_} ], sort keys %{$self->{producer_types}} ] ],
[ input => name => mt('_pedit_form_name'), short => 'name' ],
[ input => name => mt('_pedit_form_original'), short => 'original' ],
[ static => content => mt('_pedit_form_original_note') ],
[ input => name => mt('_pedit_form_alias'), short => 'alias', width => 400 ],
[ static => content => mt('_pedit_form_alias_note') ],
[ select => name => mt('_pedit_form_lang'), short => 'lang',
- options => [ map [ $_, "$_ (".mt("_lang_$_").')' ], sort @{$self->{languages}} ] ],
+ options => [ map [ $_, "$_ ($self->{languages}{$_})" ], sort keys %{$self->{languages}} ] ],
[ input => name => mt('_pedit_form_website'), short => 'website' ],
[ input => name => mt('_pedit_form_wikipedia'), short => 'l_wp', pre => 'http://en.wikipedia.org/wiki/' ],
[ text => name => mt('_pedit_form_desc').'<br /><b class="standout">'.mt('_inenglish').'</b>', short => 'desc', rows => 6 ],
@@ -385,7 +386,7 @@ sub list {
ul;
for ($perlist*$c..($perlist*($c+1))-1) {
li;
- cssicon 'lang '.$list->[$_]{lang}, mt "_lang_$list->[$_]{lang}";
+ cssicon 'lang '.$list->[$_]{lang}, $self->{languages}{$list->[$_]{lang}};
a href => "/p$list->[$_]{id}", title => $list->[$_]{original}, $list->[$_]{name};
end;
}
diff --git a/lib/VNDB/Handler/Releases.pm b/lib/VNDB/Handler/Releases.pm
index 890058af..98e95b10 100644
--- a/lib/VNDB/Handler/Releases.pm
+++ b/lib/VNDB/Handler/Releases.pm
@@ -41,7 +41,7 @@ sub page {
[ vn => join => '<br />', split => sub {
map sprintf('<a href="/v%d" title="%s">%s</a>', $_->{vid}, $_->{original}||$_->{title}, shorten $_->{title}, 50), @{$_[0]};
} ],
- [ type => serialize => sub { mt "_rtype_$_[0]" } ],
+ [ 'type' ],
[ patch => serialize => sub { mt $_[0] ? '_revision_yes' : '_revision_no' } ],
[ freeware => serialize => sub { mt $_[0] ? '_revision_yes' : '_revision_no' } ],
[ doujin => serialize => sub { mt $_[0] ? '_revision_yes' : '_revision_no' } ],
@@ -49,16 +49,14 @@ sub page {
[ original => diff => 1 ],
[ gtin => serialize => sub { $_[0]||mt '_revision_empty' } ],
[ catalog => serialize => sub { $_[0]||mt '_revision_empty' } ],
- [ languages => join => ', ', split => sub { map mt("_lang_$_"), @{$_[0]} } ],
+ [ languages => join => ', ', split => sub { map $self->{languages}{$_}, @{$_[0]} } ],
[ 'website' ],
[ released => htmlize => sub { $self->{l10n}->datestr($_[0]) } ],
[ minage => serialize => \&minage ],
[ notes => diff => qr/[ ,\n\.]/ ],
- [ platforms => join => ', ', split => sub { map mt("_plat_$_"), @{$_[0]} } ],
- [ media => join => ', ', split => sub {
- 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 } ],
+ [ platforms => join => ', ', split => sub { map $self->{platforms}{$_}, @{$_[0]} } ],
+ [ media => join => ', ', split => sub { map fmtmedia($_->{medium}, $_->{qty}), @{$_[0]} } ],
+ [ resolution => serialize => sub { $self->{resolutions}[$_[0]][0]; } ],
[ voiced => serialize => \&mtvoiced ],
[ ani_story => serialize => \&mtani ],
[ ani_ero => serialize => \&mtani ],
@@ -117,8 +115,8 @@ sub _infotable {
Tr;
td mt '_relinfo_type';
td;
- cssicon "rt$r->{type}", mt "_rtype_$r->{type}";
- txt ' '.mt '_relinfo_type_format', mt("_rtype_$r->{type}"), $r->{patch}?1:0;
+ cssicon "rt$r->{type}", $r->{type};
+ txt ' '.mt '_relinfo_type_format', ucfirst($r->{type}), $r->{patch}?1:0;
end;
end;
@@ -126,8 +124,8 @@ sub _infotable {
td mt '_relinfo_lang';
td;
for (@{$r->{languages}}) {
- cssicon "lang $_", mt "_lang_$_";
- txt ' '.mt("_lang_$_");
+ cssicon "lang $_", $self->{languages}{$_};
+ txt ' '.$self->{languages}{$_};
br if $_ ne $r->{languages}[$#{$r->{languages}}];
}
end;
@@ -143,8 +141,8 @@ sub _infotable {
td mt '_relinfo_platform', scalar @{$r->{platforms}};
td;
for(@{$r->{platforms}}) {
- cssicon $_, mt "_plat_$_";
- txt ' '.mt("_plat_$_");
+ cssicon $_, $self->{platforms}{$_};
+ txt ' '.$self->{platforms}{$_};
br if $_ ne $r->{platforms}[$#{$r->{platforms}}];
}
end;
@@ -154,17 +152,14 @@ sub _infotable {
if(@{$r->{media}}) {
Tr;
td mt '_relinfo_media', scalar @{$r->{media}};
- td join ', ', map
- $self->{media}{$_->{medium}} ? $_->{qty}.' '.mt("_med_$_->{medium}", $_->{qty}) : mt("_med_$_->{medium}",1),
- @{$r->{media}};
+ td join ', ', map fmtmedia($_->{medium}, $_->{qty}), @{$r->{media}};
end;
}
if($r->{resolution}) {
- my $res = $self->{resolutions}[$r->{resolution}][0];
Tr;
td mt '_relinfo_resolution';
- td $res =~ /^_/ ? mt $res : $res;
+ td $self->{resolutions}[$r->{resolution}][0];
end;
}
@@ -307,12 +302,12 @@ sub edit {
{ post => 'original', required => 0, default => '', maxlength => 250 },
{ post => 'gtin', required => 0, default => '0', template => 'gtin' },
{ post => 'catalog', required => 0, default => '', maxlength => 50 },
- { post => 'languages', multi => 1, enum => $self->{languages} },
+ { post => 'languages', multi => 1, enum => [ keys %{$self->{languages}} ] },
{ post => 'website', required => 0, default => '', maxlength => 250, template => 'weburl' },
{ post => 'released', required => 0, default => 0, template => 'uint' },
{ post => 'minage' , required => 0, default => -1, enum => $self->{age_ratings} },
{ post => 'notes', required => 0, default => '', maxlength => 10240 },
- { post => 'platforms', required => 0, default => '', multi => 1, enum => $self->{platforms} },
+ { post => 'platforms', required => 0, default => '', multi => 1, enum => [ keys %{$self->{platforms}} ] },
{ post => 'media', required => 0, default => '' },
{ post => 'resolution',required => 0, default => 0, enum => [ 0..$#{$self->{resolutions}} ] },
{ post => 'voiced', required => 0, default => 0, enum => $self->{voiced} },
@@ -385,7 +380,7 @@ sub _form {
$self->htmlForm({ frm => $frm, action => $r ? "/r$r->{id}/".($copy ? 'copy' : 'edit') : "/v$v->{id}/add", editsum => 1 },
rel_geninfo => [ mt('_redit_form_geninfo'),
[ select => short => 'type', name => mt('_redit_form_type'),
- options => [ map [ $_, mt "_rtype_$_" ], @{$self->{release_types}} ] ],
+ options => [ map [ $_, $_ ], @{$self->{release_types}} ] ],
[ check => short => 'patch', name => mt('_redit_form_patch') ],
[ check => short => 'freeware', name => mt('_redit_form_freeware') ],
[ check => short => 'doujin', name => mt('_redit_form_doujin') ],
@@ -393,7 +388,7 @@ sub _form {
[ input => short => 'original', name => mt('_redit_form_original'), width => 450 ],
[ static => content => mt '_redit_form_original_note' ],
[ select => short => 'languages', name => mt('_redit_form_languages'), multi => 1,
- options => [ map [ $_, "$_ (".mt("_lang_$_").')' ], sort @{$self->{languages}} ] ],
+ options => [ map [ $_, "$_ ($self->{languages}{$_})" ], sort keys %{$self->{languages}} ] ],
[ input => short => 'gtin', name => mt('_redit_form_gtin') ],
[ input => short => 'catalog', name => mt('_redit_form_catalog') ],
[ input => short => 'website', name => mt('_redit_form_website') ],
@@ -407,7 +402,7 @@ sub _form {
rel_format => [ mt('_redit_form_format'),
[ select => short => 'resolution', name => mt('_redit_form_resolution'), options => [
- map [ $_, map /^_/?mt($_):$_, @{$self->{resolutions}[$_]} ], 0..$#{$self->{resolutions}} ] ],
+ map [ $_, @{$self->{resolutions}[$_]} ], 0..$#{$self->{resolutions}} ] ],
[ select => short => 'voiced', name => mt('_redit_form_voiced'), options => [
map [ $_, mtvoiced $_ ], @{$self->{voiced}} ] ],
[ select => short => 'ani_story', name => mt('_redit_form_ani_story'), options => [
@@ -419,13 +414,13 @@ sub _form {
[ static => nolabel => 1, content => sub {
h2 mt '_redit_form_platforms';
div class => 'platforms';
- for my $p (@{$self->{platforms}}) {
+ for my $p (sort keys %{$self->{platforms}}) {
span;
input type => 'checkbox', name => 'platforms', value => $p, id => $p,
$frm->{platforms} && grep($_ eq $p, @{$frm->{platforms}}) ? (checked => 'checked') : ();
label for => $p;
- cssicon $p, mt "_plat_$p";
- txt ' '.mt("_plat_$p");
+ cssicon $p, $self->{platforms}{$p};
+ txt ' '.$self->{platforms}{$p};;
end;
end;
}
@@ -529,9 +524,9 @@ sub browse {
end;
td class => 'tc2', $l->{minage} < 0 ? '' : minage $l->{minage};
td class => 'tc3';
- $_ ne 'oth' && cssicon $_, mt "_plat_$_" for (@{$l->{platforms}});
- cssicon "lang $_", mt "_lang_$_" for (@{$l->{languages}});
- cssicon "rt$l->{type}", mt "_rtype_$l->{type}";
+ $_ ne 'oth' && cssicon $_, $self->{platforms}{$_} for (@{$l->{platforms}});
+ cssicon "lang $_", $self->{languages}{$_} for (@{$l->{languages}});
+ cssicon "rt$l->{type}", mt $l->{type};
end;
td class => 'tc4';
a href => "/r$l->{id}", title => $l->{original}||$l->{title}, shorten $l->{title}, 90;
@@ -557,8 +552,8 @@ sub _fil_compat {
my $self = shift;
my %c;
my $f = $self->formValidate(
- { get => 'ln', required => 0, multi => 1, default => '', enum => $self->{languages} },
- { get => 'pl', required => 0, multi => 1, default => '', enum => $self->{platforms} },
+ { get => 'ln', required => 0, multi => 1, default => '', enum => [ keys %{$self->{languages}} ] },
+ { get => 'pl', required => 0, multi => 1, default => '', enum => [ keys %{$self->{platforms}} ] },
{ get => 'me', required => 0, multi => 1, default => '', enum => [ keys %{$self->{media}} ] },
{ get => 'tp', required => 0, default => '', enum => [ '', @{$self->{release_types}} ] },
{ get => 'pa', required => 0, default => 0, enum => [ 0..2 ] },
diff --git a/lib/VNDB/Handler/Staff.pm b/lib/VNDB/Handler/Staff.pm
index 839d118a..5eab1192 100644
--- a/lib/VNDB/Handler/Staff.pm
+++ b/lib/VNDB/Handler/Staff.pm
@@ -37,7 +37,7 @@ sub page {
[ name => diff => 1 ],
[ original => diff => 1 ],
[ gender => serialize => sub { mt "_gender_$_[0]" } ],
- [ lang => serialize => sub { "$_[0] (".mt("_lang_$_[0]").')' } ],
+ [ lang => serialize => sub { "$_[0] ($self->{languages}{$_[0]})" } ],
[ l_site => diff => 1 ],
[ l_wp => htmlize => sub {
$_[0] ? sprintf '<a href="http://en.wikipedia.org/wiki/%s">%1$s</a>', xml_escape $_[0] : mt '_revision_nolink'
@@ -69,7 +69,7 @@ sub page {
end;
Tr;
td class => 'key', mt '_staff_language';
- td mt "_lang_$s->{lang}";
+ td $self->{languages}{$s->{lang}};
end;
if(@{$s->{aliases}}) {
Tr;
@@ -205,7 +205,7 @@ sub edit {
{ post => 'primary', required => 0, template => 'id', default => 0 },
{ post => 'desc', required => 0, maxlength => 5000, default => '' },
{ post => 'gender', required => 0, default => 'unknown', enum => [qw|unknown m f|] },
- { post => 'lang', enum => $self->{languages} },
+ { post => 'lang', enum => [ keys %{$self->{languages}} ] },
{ post => 'l_wp', required => 0, maxlength => 150, default => '' },
{ post => 'l_site', required => 0, template => 'weburl', maxlength => 250, default => '' },
{ post => 'l_twitter', required => 0, maxlength => 16, default => '', regex => [ qr/^\S+$/, mt('_staffe_form_tw_err') ] },
@@ -277,7 +277,7 @@ sub edit {
[ select => name => mt('_staffe_form_gender'),short => 'gender', options => [
map [ $_, mt("_gender_$_") ], qw(unknown m f) ] ],
[ select => name => mt('_staffe_form_lang'), short => 'lang',
- options => [ map [ $_, "$_ (".mt("_lang_$_").')' ], sort @{$self->{languages}} ] ],
+ options => [ map [ $_, "$_ ($self->{languages}{$_})" ], sort keys %{$self->{languages}} ] ],
[ input => name => mt('_staffe_form_site'), short => 'l_site' ],
[ input => name => mt('_staffe_form_wikipedia'), short => 'l_wp', pre => 'http://en.wikipedia.org/wiki/' ],
[ input => name => mt('_staffe_form_twitter'), short => 'l_twitter' ],
@@ -348,7 +348,7 @@ sub list {
for ($perlist*$c..($perlist*($c+1))-1) {
li;
my $gender = $list->[$_]{gender};
- cssicon 'lang '.$list->[$_]{lang}, mt "_lang_$list->[$_]{lang}";
+ cssicon 'lang '.$list->[$_]{lang}, $self->{languages}{$list->[$_]{lang}};
a href => "/s$list->[$_]{id}",
title => $list->[$_]{original}, $list->[$_]{name};
end;
diff --git a/lib/VNDB/Handler/ULists.pm b/lib/VNDB/Handler/ULists.pm
index b2e84ac3..888e0b8b 100644
--- a/lib/VNDB/Handler/ULists.pm
+++ b/lib/VNDB/Handler/ULists.pm
@@ -474,8 +474,8 @@ sub _vnlist_browse {
lit $self->{l10n}->datestr($_->{released});
end;
td class => 'tc4';
- cssicon "lang $_", mt "_lang_$_" for @{$_->{languages}};
- cssicon "rt$_->{type}", mt "_rtype_$_->{type}";
+ cssicon "lang $_", $self->{languages}{$_} for @{$_->{languages}};
+ cssicon "rt$_->{type}", $_->{type};
end;
td class => 'tc5';
a href => "/r$_->{rid}", title => $_->{original}||$_->{title}, shorten $_->{title}, 50;
diff --git a/lib/VNDB/Handler/VNBrowse.pm b/lib/VNDB/Handler/VNBrowse.pm
index 01f5bc61..cef51f11 100644
--- a/lib/VNDB/Handler/VNBrowse.pm
+++ b/lib/VNDB/Handler/VNBrowse.pm
@@ -122,8 +122,8 @@ sub _fil_compat {
my $self = shift;
my %c;
my $f = $self->formValidate(
- { get => 'ln', required => 0, multi => 1, enum => $self->{languages}, default => '' },
- { get => 'pl', required => 0, multi => 1, enum => $self->{platforms}, default => '' },
+ { get => 'ln', required => 0, multi => 1, enum => [ keys %{$self->{languages}} ], default => '' },
+ { get => 'pl', required => 0, multi => 1, enum => [ keys %{$self->{platforms}} ], default => '' },
{ get => 'sp', required => 0, default => ($self->reqCookie('tagspoil')||'') =~ /^([0-2])$/ ? $1 : 0, enum => [0..2] },
);
return () if $f->{_err};
diff --git a/lib/VNDB/Handler/VNEdit.pm b/lib/VNDB/Handler/VNEdit.pm
index 220da8af..3d7b9db4 100644
--- a/lib/VNDB/Handler/VNEdit.pm
+++ b/lib/VNDB/Handler/VNEdit.pm
@@ -113,7 +113,7 @@ sub edit {
{ post => 'original', required => 0, maxlength => 250, default => '' },
{ post => 'alias', required => 0, maxlength => 500, default => '' },
{ post => 'desc', required => 0, default => '', maxlength => 10240 },
- { post => 'length', required => 0, default => 0, enum => $self->{vn_lengths} },
+ { post => 'length', required => 0, default => 0, enum => [ 0..$#{$self->{vn_lengths}} ] },
{ post => 'l_wp', required => 0, default => '', maxlength => 150 },
{ post => 'l_encubed', required => 0, default => '', maxlength => 100 },
{ post => 'l_renai', required => 0, default => '', maxlength => 100 },
@@ -258,7 +258,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 [ $_ => mtvnlen $_, 2 ], @{$self->{vn_lengths}} ] ],
+ [ map [ $_ => fmtvnlen $_, 2 ], 0..$#{$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 74969a8b..1439a007 100644
--- a/lib/VNDB/Handler/VNPage.pm
+++ b/lib/VNDB/Handler/VNPage.pm
@@ -33,6 +33,7 @@ sub rg {
return if $self->htmlRGHeader($title, 'v', $v);
$v->{svg} =~ s/id="node_v$vid"/id="graph_current"/;
+ # TODO: The relation string can be properly interned in the SVG now
$v->{svg} =~ s/\$___(_vnrel_[a-z]+)____\$/mt $1/eg;
div class => 'mainbox';
@@ -67,7 +68,7 @@ my @rel_cols = (
sort_field => 'type',
button_string => '_relinfo_type',
default => 1,
- draw => sub { cssicon "rt$_[0]{type}", mt "_rtype_$_[0]{type}"; txt mt '_vnpage_rel_patch' if $_[0]{patch} },
+ draw => sub { cssicon "rt$_[0]{type}", $_[0]{type}; txt mt '_vnpage_rel_patch' if $_[0]{patch} },
}, { # Languages
id => 'lan',
button_string => '_relinfo_lang',
@@ -75,7 +76,7 @@ my @rel_cols = (
has_data => sub { !!@{$_[0]{languages}} },
draw => sub {
for(@{$_[0]{languages}}) {
- cssicon "lang $_", mt "_lang_$_";
+ cssicon "lang $_", $TUWF::OBJ->{languages}{$_};
br if $_ ne $_[0]{languages}[$#{$_[0]{languages}}];
}
},
@@ -96,7 +97,7 @@ my @rel_cols = (
has_data => sub { !!@{$_[0]{platforms}} },
draw => sub {
for(@{$_[0]{platforms}}) {
- cssicon $_, mt "_plat_$_";
+ cssicon $_, $TUWF::OBJ->{platforms}{$_};
br if $_ ne $_[0]{platforms}[$#{$_[0]{platforms}}];
}
txt mt '_unknown' if !@{$_[0]{platforms}};
@@ -109,7 +110,7 @@ my @rel_cols = (
has_data => sub { !!@{$_[0]{media}} },
draw => sub {
for(@{$_[0]{media}}) {
- txt $TUWF::OBJ->{media}{$_->{medium}} ? $_->{qty}.' '.mt("_med_$_->{medium}", $_->{qty}) : mt("_med_$_->{medium}",1);
+ txt fmtmedia($_->{medium}, $_->{qty});
br if $_ ne $_[0]{media}[$#{$_[0]{media}}];
}
txt mt '_unknown' if !@{$_[0]{media}};
@@ -125,8 +126,7 @@ my @rel_cols = (
has_data => sub { !!$_[0]{resolution} },
draw => sub {
if($_[0]{resolution}) {
- my $res = $TUWF::OBJ->{resolutions}[$_[0]{resolution}][0];
- txt $res =~ /^_/ ? mt $res : $res;
+ txt $TUWF::OBJ->{resolutions}[$_[0]{resolution}][0];
} else {
txt mt '_unknown';
}
@@ -200,8 +200,8 @@ sub releases {
{ get => 'cw', required => 0, default => 0, enum => [0,1] },
{ get => 'o', required => 0, default => 0, enum => [0,1] },
{ get => 's', required => 0, default => 'released', enum => [ map $_->{sort_field}, grep $_->{sort_field}, @rel_cols ]},
- { get => 'os', required => 0, default => 'all', enum => [ 'all', @{$self->{platforms}} ] },
- { get => 'lang', required => 0, default => 'all', enum => [ 'all', @{$self->{languages}} ] },
+ { get => 'os', required => 0, default => 'all', enum => [ 'all', keys %{$self->{platforms}} ] },
+ { get => 'lang', required => 0, default => 'all', enum => [ 'all', keys %{$self->{languages}} ] },
);
return $self->resNotFound if $f->{_err};
@@ -251,19 +251,19 @@ sub _releases_buttons {
# Platform/language filters
my $plat_lang_draw = sub {
- my($row, $option, $l10nprefix, $csscat) = @_;
+ my($row, $option, $txt, $csscat) = @_;
my %opts = map +($_,1), map @{$_->{$row}}, @$r;
return if !keys %opts;
p class => 'browseopts';
for('all', sort keys %opts) {
a href => $url->($option, $_), $_ eq $f->{$option} ? (class => 'optselected') : ();
- $_ eq 'all' ? txt mt '_all' : cssicon "$csscat $_", mt $l10nprefix.$_;
+ $_ eq 'all' ? txt mt '_all' : cssicon "$csscat $_", $txt->{$_};
end 'a';
}
end 'p';
};
- $plat_lang_draw->('platforms', 'os', '_plat_', '') if $f->{pla};
- $plat_lang_draw->('languages', 'lang','_lang_', 'lang') if $f->{lan};
+ $plat_lang_draw->('platforms', 'os', $self->{platforms}, '') if $f->{pla};
+ $plat_lang_draw->('languages', 'lang',$self->{languages}, 'lang') if $f->{lan};
}
@@ -399,7 +399,7 @@ sub page {
if($v->{length}) {
Tr;
td mt '_vnpage_length';
- td mtvnlen $v->{length}, 1;
+ td fmtvnlen $v->{length}, 1;
end;
}
my @links = (
@@ -506,7 +506,7 @@ sub _revision {
[ original => diff => 1 ],
[ alias => diff => qr/[ ,\n\.]/ ],
[ desc => diff => qr/[ ,\n\.]/ ],
- [ length => serialize => sub { mtvnlen $_[0] } ],
+ [ length => serialize => sub { fmtvnlen $_[0] } ],
[ l_wp => htmlize => sub {
$_[0] ? sprintf '<a href="http://en.wikipedia.org/wiki/%s">%1$s</a>', xml_escape $_[0] : mt '_revision_nolink'
}],
@@ -591,7 +591,7 @@ sub _producers {
my %p = map $_->{publisher} ? ($_->{id} => $_) : (), map @{$_->{producers}}, grep grep($_ eq $l, @{$_->{languages}}), @$r;
my @p = values %p;
next if !@p;
- cssicon "lang $l", mt "_lang_$l";
+ cssicon "lang $l", $self->{languages}{$l};
for (@p) {
a href => "/p$_->{id}", title => $_->{original}||$_->{name}, shorten $_->{name}, 30;
txt ' & ' if $_ != $p[$#p];
@@ -658,7 +658,7 @@ sub _anime {
txt '] ';
end;
abbr title => $_->{title_kanji}||$_->{title_romaji}, shorten $_->{title_romaji}, 50;
- b ' ('.(defined $_->{type} ? mt("_animetype_$_->{type}").', ' : '').$_->{year}.')';
+ b ' ('.(defined $_->{type} ? $self->{anime_types}{$_->{type}}.', ' : '').$_->{year}.')';
br;
}
}
@@ -728,8 +728,8 @@ sub _affiliate_links {
for my $link (@$links) {
my $f = $self->{affiliates}[$link->{affiliate}];
my $rel = $r{$link->{rid}};
- my $plat = join(' and ', map $en->maketext("_plat_$_"), @{$rel->{platforms}});
- my $version = join(' and ', map $en->maketext("_lang_$_"), @{$rel->{languages}}).' '.$plat.' version';
+ my $plat = join(' and ', map $self->{platforms}{$_}, @{$rel->{platforms}});
+ my $version = join(' and ', map $self->{languages}{$_}, @{$rel->{languages}}).' '.$plat.' version';
a rel => 'nofollow', href => $f->{link_format} ? $f->{link_format}->($link->{url}) : $link->{url};
use utf8;
@@ -775,8 +775,8 @@ sub _releases {
for my $l (@lang) {
Tr class => 'lang';
td colspan => 6;
- cssicon "lang $l", mt "_lang_$l";
- txt mt "_lang_$l";
+ cssicon "lang $l", $self->{languages}{$l};
+ txt $self->{languages}{$l};
end;
end;
for my $rel (grep grep($_ eq $l, @{$_->{languages}}), @$r) {
@@ -786,9 +786,9 @@ sub _releases {
td class => 'tc3';
for (sort @{$rel->{platforms}}) {
next if $_ eq 'oth';
- cssicon $_, mt "_plat_$_";
+ cssicon $_, $self->{platforms}{$_};
}
- cssicon "rt$rel->{type}", mt "_rtype_$rel->{type}";
+ cssicon "rt$rel->{type}", $rel->{type};
end;
td class => 'tc4';
a href => "/r$rel->{id}", title => $rel->{original}||$rel->{title}, $rel->{title};
@@ -840,7 +840,7 @@ sub _screenshots {
my @scr = grep $_->{rid} && $rel->{id} == $_->{rid}, @{$v->{screenshots}};
next if !@scr;
p class => 'rel';
- cssicon "lang $_", mt "_lang_$_" for (@{$rel->{languages}});
+ cssicon "lang $_", $self->{languages}{$_} for (@{$rel->{languages}});
a href => "/r$rel->{id}", $rel->{title};
end;
div class => 'scr';