summaryrefslogtreecommitdiff
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
parentca1a9c48c24a436babd30ad9e315db2781364879 (diff)
L10N: Intern languages/platforms/resolutions/media/ptype/rtype/vnlength
-rw-r--r--data/global.pl143
-rw-r--r--data/lang.txt311
-rw-r--r--lib/Multi/API.pm8
-rw-r--r--lib/VNDB/Func.pm23
-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
-rw-r--r--lib/VNDB/Util/BrowseHTML.pm4
-rwxr-xr-xutil/jsgen.pl19
14 files changed, 227 insertions, 462 deletions
diff --git a/data/global.pl b/data/global.pl
index ca1df4d3..67254c0b 100644
--- a/data/global.pl
+++ b/data/global.pl
@@ -1,6 +1,8 @@
package VNDB;
+use utf8;
+
# options for TUWF
our %O = (
db_login => [ 'dbi:Pg:dbname=vndb', 'vndb', 'passwd' ],
@@ -35,13 +37,62 @@ our %S;
permissions => {qw| board 1 boardmod 2 edit 4 tag 16 dbmod 32 tagmod 64 usermod 128 affiliate 256 |},
default_perm => 1+4+16, # Keep synchronised with the default value of users.perm
default_tags_cat=> 'cont,tech',
- languages => [qw|ar ca cs da de en es fi fr he hu id it ja ko nl no pl pt-br pt-pt ro ru sk sv tr uk vi zh|],
- producer_types => [qw|co in ng|],
+ languages => {grep !/^ *$/, split /[\s\r\n]*([^ ]+) +(.+)/, q{
+ ar Arabic
+ ca Catalan
+ cs Czech
+ da Danish
+ de German
+ en English
+ es Spanish
+ fi Finnish
+ fr French
+ he Hebrew
+ hu Hungarian
+ id Indonesian
+ it Italian
+ ja Japanese
+ ko Korean
+ nl Dutch
+ no Norwegian
+ pl Polish
+ pt-br Portuguese (Brazil)
+ pt-pt Portuguese (Portugal)
+ ro Romanian
+ ru Russian
+ sk Slovak
+ sv Swedish
+ tr Turkish
+ uk Ukrainian
+ vi Vietnamese
+ zh Chinese
+ }},
+ producer_types => {
+ co => 'Company',
+ in => 'Individual',
+ ng => 'Amateur group',
+ },
discussion_boards => [qw|an db ge v p u|], # <- note that some properties of these boards are hard-coded
- vn_lengths => [ 0..5 ],
- anime_types => [qw|tv ova mov oth web spe mv|],
+ vn_lengths => [
+ # name time examples
+ [ 'Unknown', '', '' ],
+ [ 'Very short', '< 2 hours', 'OMGWTFOTL, Jouka no Monshou, The world to reverse' ],
+ [ 'Short', '2 - 10 hours', 'Narcissu, Saya no Uta, Planetarian' ],
+ [ 'Medium', '10 - 30 hours', 'Yume Miru Kusuri, Cross†Channel, Crescendo' ],
+ [ 'Long', '30 - 50 hours', 'Tsukihime, Ever17, Demonbane' ],
+ [ 'Very long', '> 50 hours', 'Clannad, Umineko, Fate/Stay Night' ],
+ ],
+ anime_types => {
+ tv => 'TV Series',
+ ova => 'OVA',
+ mov => 'Movie',
+ oth => 'Other',
+ web => 'Web',
+ spe => 'TV Special',
+ mv => 'Music Video',
+ },
board_edit_time => 7*24*3600,
- vn_relations => {
+ vn_relations => {
# id => [ order, reverse ]
seq => [ 0, 'preq' ],
preq => [ 1, 'seq' ],
@@ -67,37 +118,73 @@ our %S;
age_ratings => [-1, 0, 6..18],
release_types => [qw|complete partial trial|],
# The 'unk' platform and medium are reserved for "unknown".
- platforms => [qw|win dos lin mac ios and dvd bdp fmt gba gbc msx nds nes p88 p98 pce pcf psp ps1 ps2 ps3 ps4 psv drc sat sfc wii n3d x68 xb1 xb3 xbo web oth|],
+ platforms => {grep !/^ *$/, split /[\s\r\n]*([^ ]+) +(.+)/, q{
+ win Windows
+ dos DOS
+ lin Linux
+ mac Mac OS
+ ios Apple iProduct
+ and Android
+ dvd DVD Player
+ bdp Blu-ray Player
+ fmt FM Towns
+ gba Game Boy Advance
+ gbc Game Boy Color
+ msx MSX
+ nds Nintendo DS
+ nes Famicom
+ p88 PC-88
+ p98 PC-98
+ pce PC Engine
+ pcf PC-FX
+ psp PlayStation Portable
+ ps1 PlayStation 1
+ ps2 PlayStation 2
+ ps3 PlayStation 3
+ ps4 PlayStation 4
+ psv PlayStation Vita
+ drc Dreamcast
+ sat Sega Saturn
+ sfc Super Nintendo
+ wii Nintendo Wii
+ n3d Nintendo 3DS
+ x68 X68000
+ xb1 Xbox
+ xb3 Xbox 360
+ xbo Xbox One
+ web Website
+ oth Other
+ }},
media => {
- #DB qty?
- cd => 1,
- dvd => 1,
- gdr => 1,
- blr => 1,
- flp => 1,
- mrt => 1,
- mem => 1,
- umd => 1,
- nod => 1,
- in => 0,
- otc => 0
+ #DB qty txt plural (if qty)
+ cd => [ 1, 'CD', 'CDs' ],
+ dvd => [ 1, 'DVD', 'DVDs' ],
+ gdr => [ 1, 'GD-ROM', 'GD-ROMs' ],
+ blr => [ 1, 'Blu-ray disc', 'Blu-ray discs' ],
+ flp => [ 1, 'Floppy', 'Floppies' ],
+ mrt => [ 1, 'Cartridge', 'Cartridges' ],
+ mem => [ 1, 'Memory card', 'Memory cards' ],
+ umd => [ 1, 'UMD', 'UMDs' ],
+ nod => [ 1, 'Nintendo Optical Disc', 'Nintendo Optical Discs' ],
+ in => [ 0, 'Internet download', '' ],
+ otc => [ 0, 'Other', '' ],
},
resolutions => [
- [ '_scrres_unknown', '' ],
- [ '_scrres_nonstandard', '' ],
+ [ 'Unknown / console / handheld', '' ],
+ [ 'Non-standard', '' ],
[ '640x480', '4:3' ],
[ '800x600', '4:3' ],
[ '1024x768', '4:3' ],
[ '1280x960', '4:3' ],
[ '1600x1200', '4:3' ],
- [ '640x400', '_scrres_ws' ],
- [ '960x600', '_scrres_ws' ],
- [ '1024x576', '_scrres_ws' ],
- [ '1024x600', '_scrres_ws' ],
- [ '1024x640', '_scrres_ws' ],
- [ '1280x720', '_scrres_ws' ],
- [ '1280x800', '_scrres_ws' ],
- [ '1920x1080', '_scrres_ws' ],
+ [ '640x400', 'widescreen' ],
+ [ '960x600', 'widescreen' ],
+ [ '1024x576', 'widescreen' ],
+ [ '1024x600', 'widescreen' ],
+ [ '1024x640', 'widescreen' ],
+ [ '1280x720', 'widescreen' ],
+ [ '1280x800', 'widescreen' ],
+ [ '1920x1080', 'widescreen' ],
],
tag_categories => [ qw|cont ero tech| ],
voiced => [ 0..4 ],
diff --git a/data/lang.txt b/data/lang.txt
index 8ad53799..bd056f7e 100644
--- a/data/lang.txt
+++ b/data/lang.txt
@@ -38,239 +38,6 @@ information.
en : Unknown
-# languages
-
-:_lang_ar
-en : Arabic
-
-:_lang_ca
-en : Catalan
-
-:_lang_cs
-en : Czech
-
-:_lang_da
-en : Danish
-
-:_lang_de
-en : German
-
-:_lang_en
-en : English
-
-:_lang_es
-en : Spanish
-
-:_lang_fi
-en : Finnish
-
-:_lang_fr
-en : French
-
-:_lang_he
-en : Hebrew
-
-:_lang_hu
-en : Hungarian
-
-:_lang_id
-en : Indonesian
-
-:_lang_it
-en : Italian
-
-:_lang_ja
-en : Japanese
-
-:_lang_ko
-en : Korean
-
-:_lang_nl
-en : Dutch
-
-:_lang_no
-en : Norwegian
-
-:_lang_pl
-en : Polish
-
-:_lang_pt-br
-en : Portuguese (Brazil)
-
-:_lang_pt-pt
-en : Portuguese (Portugal)
-
-:_lang_ro
-en : Romanian
-
-:_lang_ru
-en : Russian
-
-:_lang_sk
-en : Slovak
-
-:_lang_sv
-en : Swedish
-
-:_lang_tr
-en : Turkish
-
-:_lang_uk
-en : Ukrainian
-
-:_lang_vi
-en : Vietnamese
-
-:_lang_zh
-en : Chinese
-
-
-# platforms
-# most of these probably don't need TL in most languages, but some
-# languages (i.e. Japanese) do use different names for products
-
-:_plat_win
-en : Windows
-
-:_plat_dos
-en : DOS
-
-:_plat_lin
-en : Linux
-
-:_plat_mac
-en : Mac OS
-
-:_plat_ios
-en : Apple iProduct
-
-:_plat_and
-en : Android
-
-:_plat_dvd
-en : DVD Player
-
-:_plat_bdp
-en : Blu-ray Player
-
-:_plat_fmt
-en : FM Towns
-
-:_plat_gba
-en : Game Boy Advance
-
-:_plat_gbc
-en : Game Boy Color
-
-:_plat_msx
-en : MSX
-
-:_plat_nds
-en : Nintendo DS
-
-:_plat_nes
-en : Famicom
-
-:_plat_p88
-en : PC-88
-
-:_plat_p98
-en : PC-98
-
-:_plat_pce
-en : PC Engine
-
-:_plat_pcf
-en : PC-FX
-
-:_plat_psp
-en : PlayStation Portable
-
-:_plat_ps1
-en : PlayStation 1
-
-:_plat_ps2
-en : PlayStation 2
-
-:_plat_ps3
-en : PlayStation 3
-
-:_plat_ps4
-en : PlayStation 4
-
-:_plat_psv
-en : PlayStation Vita
-
-:_plat_drc
-en : Dreamcast
-
-:_plat_sat
-en : Sega Saturn
-
-:_plat_sfc
-en : Super Nintendo
-
-:_plat_wii
-en : Nintendo Wii
-
-:_plat_n3d
-en : Nintendo 3DS
-
-:_plat_x68
-en : X68000
-
-:_plat_xb1
-en : Xbox
-
-:_plat_xb3
-en : Xbox 360
-
-:_plat_xbo
-en : Xbox One
-
-:_plat_web
-en : Website
-
-:_plat_oth
-en : Other
-
-
-# Release media
-
-:_med_cd
-en : [quant,_1,CD,CDs]
-
-:_med_dvd
-en : [quant,_1,DVD,DVDs]
-
-:_med_gdr
-en : [quant,_1,GD-ROM,GD-ROMs]
-
-:_med_blr
-en : [quant,_1,Blu-ray disc,Blu-ray discs]
-
-:_med_flp
-en : [quant,_1,Floppy,Floppies]
-
-:_med_mrt
-en : [quant,_1,Cartridge,Cartridges]
-
-:_med_mem
-en : [quant,_1,Memory card,Memory cards]
-
-:_med_umd
-en : [quant,_1,UMD,UMDs]
-
-:_med_nod
-en : Nintendo Optical [quant,_1,Disk,Disks]
-
-:_med_in
-en : Internet download
-
-:_med_otc
-en : Other
-
-
# VN relations
:_vnrel_seq
@@ -304,18 +71,6 @@ en : Fandisc
en : Original game
-# producer types
-
-:_ptype_co
-en : Company
-
-:_ptype_in
-en : Individual
-
-:_ptype_ng
-en : Amateur group
-
-
# producer relations
:_prodrel_old
@@ -343,42 +98,6 @@ en : Spawned
en : Originated from
-# release types
-
-:_rtype_complete
-en : Complete
-
-:_rtype_partial
-en : Partial
-
-:_rtype_trial
-en : Trial
-
-
-# Anime types
-
-:_animetype_tv
-en : TV Series
-
-:_animetype_ova
-en : OVA
-
-:_animetype_mov
-en : Movie
-
-:_animetype_oth
-en : Other
-
-:_animetype_web
-en : Web
-
-:_animetype_spe
-en : TV Special
-
-:_animetype_mv
-en : Music Video
-
-
# Discussion board types
:_dboard_an
@@ -415,18 +134,6 @@ en : low
en : blacklist
-# screen resolutions
-
-:_scrres_unknown
-en : Unknown / console / handheld
-
-:_scrres_nonstandard
-en : Non-standard
-
-:_scrres_ws
-en : widescreen
-
-
# 'Voiced' information for releases
:_voiced_1
@@ -490,24 +197,6 @@ en : excellent
en : masterpiece
-# VN lengths
-
-:_vnlength_1
-en : Very short[index,_1,, (< 2 hours), (OMGWTFOTL~, Jouka no Monshou~, The world to reverse)]
-
-:_vnlength_2
-en : Short[index,_1,, (2 - 10 hours), (Narcissu~, Saya no Uta~, Planetarian)]
-
-:_vnlength_3
-en : Medium[index,_1,, (10 - 30 hours), (Yume Miru Kusuri~, Cross†Channel~, Crescendo)]
-
-:_vnlength_4
-en : Long[index,_1,, (30 - 50 hours), (Tsukihime~, Ever17~, Demonbane)]
-
-:_vnlength_5
-en : Very long[index,_1,, (> 50 hours), (Clannad~, Umineko~, Fate/Stay Night)]
-
-
# VN list statuses
:_rlist_status_1
diff --git a/lib/Multi/API.pm b/lib/Multi/API.pm
index 256a4532..75922ea1 100644
--- a/lib/Multi/API.pm
+++ b/lib/Multi/API.pm
@@ -562,7 +562,7 @@ my %GET_RELEASE = (
}
for (@$r) {
delete $_->{id};
- $_->{qty} = $VNDB::S{media}{$_->{medium}} ? $_->{qty}*1 : undef;
+ $_->{qty} = $VNDB::S{media}{$_->{medium}}[0] ? $_->{qty}*1 : undef;
}
} ],
]
@@ -706,7 +706,7 @@ my %GET_PRODUCER = (
],
type => [
[ str => 'p.type :op: :value:', {qw|= = != <>|},
- process => sub { !grep($_ eq $_[0], @{$VNDB::S{producer_types}}) ? \'No such producer type' : $_[0] } ],
+ process => sub { !$VNDB::S{producer_types}{$_[0]} ? \'No such producer type' : $_[0] } ],
],
language => [
[ str => 'p.lang :op: :value:', {qw|= = != <>|}, process => \'lang' ],
@@ -945,9 +945,9 @@ sub get_filters {
y/%//;
$v = "%$v%";
} elsif(${$o{process}} eq 'lang') {
- return cerr $c, filter => 'Invalid language code', %e if !grep $v eq $_, @{$VNDB::S{languages}};
+ return cerr $c, filter => 'Invalid language code', %e if !$VNDB::S{languages}{$v};
} elsif(${$o{process}} eq 'plat') {
- return cerr $c, filter => 'Invalid platform code', %e if !grep $v eq $_, @{$VNDB::S{platforms}};
+ return cerr $c, filter => 'Invalid platform code', %e if !$VNDB::S{platforms}{$v};
}
}
diff --git a/lib/VNDB/Func.pm b/lib/VNDB/Func.pm
index 2644ea35..693d378f 100644
--- a/lib/VNDB/Func.pm
+++ b/lib/VNDB/Func.pm
@@ -10,9 +10,9 @@ use JSON::XS;
use VNDBUtil;
our @EXPORT = (@VNDBUtil::EXPORT, qw|
clearfloat cssicon tagscore mt minage fil_parse fil_serialize parenttags
- childtags charspoil imgpath imgurl fmtvote
+ childtags charspoil imgpath imgurl fmtvote fmtmedia fmtvnlen
json_encode json_decode script_json
- mtvoiced mtani mtvnlen mtrlstat mtvnlstat mtbloodt
+ mtvoiced mtani mtrlstat mtvnlstat mtbloodt
form_compare
|);
@@ -204,6 +204,24 @@ sub fmtvote {
return !$_[0] ? '-' : $_[0] % 10 == 0 ? $_[0]/10 : sprintf '%.1f', $_[0]/10;
}
+# Formats a media string ("1 CD", "2 CDs", "Internet download", etc)
+sub fmtmedia {
+ my($med, $qty) = @_;
+ $med = $TUWF::OBJ->{media}{$med};
+ join ' ',
+ ($med->[0] ? ($qty) : ()),
+ $med->[ $med->[0] && $qty > 1 ? 2 : 1 ];
+}
+
+# Formats a VN length (xtra = 1 for time indication, 2 for examples)
+sub fmtvnlen {
+ my($len, $xtra) = @_;
+ $len = $TUWF::OBJ->{vn_lengths}[$len];
+ $len->[0].
+ ($xtra && $xtra == 1 && $len->[1] ? " ($len->[1])" : '').
+ ($xtra && $xtra == 2 && $len->[2] ? " ($len->[2])" : '');
+}
+
# JSON::XS::encode_json converts input to utf8, whereas the below functions
# operate on wide character strings. Canonicalization is enabled to allow for
@@ -233,7 +251,6 @@ sub script_json {
# 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]; }
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';
diff --git a/lib/VNDB/Util/BrowseHTML.pm b/lib/VNDB/Util/BrowseHTML.pm
index b4510079..5c4ab938 100644
--- a/lib/VNDB/Util/BrowseHTML.pm
+++ b/lib/VNDB/Util/BrowseHTML.pm
@@ -198,11 +198,11 @@ sub htmlBrowseVN {
}
td class => 'tc8', defined($l->{wstat}) ? mt "_wish_$l->{wstat}" : '' if $f->{wish};
td class => 'tc2';
- $_ ne 'oth' && cssicon $_, mt "_plat_$_"
+ $_ ne 'oth' && cssicon $_, $self->{platforms}{$_}
for (sort @{$l->{c_platforms}});
end;
td class => 'tc3';
- cssicon "lang $_", mt "_lang_$_"
+ cssicon "lang $_", $self->{languages}{$_}
for (reverse sort @{$l->{c_languages}});
end;
td class => 'tc4';
diff --git a/util/jsgen.pl b/util/jsgen.pl
index 36adea0d..ba18b983 100755
--- a/util/jsgen.pl
+++ b/util/jsgen.pl
@@ -101,19 +101,17 @@ sub l10n {
# screen resolution information, suitable for usage in filFSelect()
sub resolutions {
- my $ln = shift;
my $cat = '';
my @r;
my $push = \@r;
for my $i (0..$#{$S{resolutions}}) {
my $r = $S{resolutions}[$i];
if($cat ne $r->[1]) {
- push @r, [$r->[1] =~ /^_/ ? l10nstr($ln, $r->[1]) : $r->[1]];
+ push @r, [$r->[1]];
$cat = $r->[1];
$push = $r[$#r];
}
- my $n = $r->[0] =~ /^_/ ? l10nstr($ln, $r->[0]) : $r->[0];
- push @$push, [$i, $n];
+ push @$push, [$i, $r->[0]];
}
\@r
}
@@ -125,19 +123,18 @@ sub vars {
rlist_status => [ map l10nstr($lang, $_?"_rlist_status_$_":'_unknown'), @{$S{rlist_status}} ],
cookie_prefix => $O{cookie_prefix},
age_ratings => [ map [ $_, l10nstr($lang, $_ == -1 ? ('_unknown') : $_ == 0 ? ('_minage_all') : ('_minage_age', $_)) ], @{$S{age_ratings}} ],
- languages => [ map [ $_, l10nstr($lang, "_lang_$_") ], @{$S{languages}} ],
- platforms => [ map [ $_, l10nstr($lang, "_plat_$_") ], @{$S{platforms}} ],
+ languages => [ map [ $_, $S{languages}{$_} ], sort keys %{$S{languages}} ],
+ platforms => [ map [ $_, $S{platforms}{$_} ], sort keys %{$S{platforms}} ],
char_roles => [ map [ $_, l10nstr($lang, "_charrole_$_") ], @{$S{char_roles}} ],
- media => [ map [ $_, l10nstr($lang, "_med_$_"), $S{media}{$_} ], sort keys %{$S{media}} ],
- release_types => [ map [ $_, l10nstr($lang, "_rtype_$_") ], @{$S{release_types}} ],
+ media => [ map [ $_, $S{media}{$_}[1], $S{media}{$_}[0] ], sort keys %{$S{media}} ],
+ release_types => [ map [ $_, ucfirst $_ ], @{$S{release_types}} ],
animated => [ map [ 1*$_, l10nstr($lang, $_?"_animated_$_":'_unknown' ) ], @{$S{animated}} ],
voiced => [ map [ 1*$_, l10nstr($lang, $_?"_voiced_$_":'_unknown' ) ], @{$S{voiced}} ],
- vn_lengths => [ map [ 1*$_, l10nstr($lang, $_?"_vnlength_$_":'_unknown' ) ], @{$S{vn_lengths}} ],
+ vn_lengths => [ map [ $_, $S{vn_lengths}[$_][0] ], 0..$#{$S{vn_lengths}} ],
blood_types => [ map [ $_, l10nstr($lang, $_ eq 'unknown' ? '_unknown' : "_bloodt_$_") ], @{$S{blood_types}} ],
genders => [ map [ $_, l10nstr($lang, "_gender_$_") ], @{$S{genders}} ],
staff_roles => [ map [ $_, l10nstr($lang, "_credit_$_") ], @{$S{staff_roles}} ],
- resolutions => scalar resolutions($lang),
- l10n_lang => [ map [ $_, l10nstr($_, "_lang_$_") ], VNDB::L10N::languages() ],
+ resolutions => scalar resolutions(),
l10n_str => $l10n,
);
JSON::XS->new->encode(\%vars);