summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2019-09-11 15:56:54 +0200
committerYorhel <git@yorhel.nl>2019-09-11 15:56:54 +0200
commit7eca65c37be71d9c677cc99153e0df75902ed8cb (patch)
treed3b13511e0169f0f6f5a731c7969420d2cdf56f8
parent8c1faad14d4e4be29c464a3dcf3e2f340c6f8242 (diff)
VNDB::Types: Convert languages into %LANGUAGE
-rw-r--r--data/global.pl36
-rw-r--r--lib/Multi/API.pm3
-rw-r--r--lib/Multi/RG.pm3
-rw-r--r--lib/VN3/ElmGen.pm2
-rw-r--r--lib/VN3/Producer/Page.pm2
-rw-r--r--lib/VN3/Release/Page.pm2
-rw-r--r--lib/VN3/Staff/Page.pm2
-rw-r--r--lib/VN3/Types.pm40
-rw-r--r--lib/VN3/VN/Page.pm4
-rw-r--r--lib/VN3/Validation.pm2
-rw-r--r--lib/VNDB/Handler/Misc.pm5
-rw-r--r--lib/VNDB/Handler/Producers.pm13
-rw-r--r--lib/VNDB/Handler/Releases.pm15
-rw-r--r--lib/VNDB/Handler/Staff.pm10
-rw-r--r--lib/VNDB/Handler/VNBrowse.pm3
-rw-r--r--lib/VNDB/Handler/VNPage.pm14
-rw-r--r--lib/VNDB/Types.pm39
-rw-r--r--lib/VNDB/Util/BrowseHTML.pm3
-rwxr-xr-xutil/jsgen.pl2
19 files changed, 86 insertions, 114 deletions
diff --git a/data/global.pl b/data/global.pl
index 0b79f44d..058d9508 100644
--- a/data/global.pl
+++ b/data/global.pl
@@ -48,42 +48,6 @@ our %S;
permissions => {qw| board 1 boardmod 2 edit 4 tag 16 dbmod 32 tagmod 64 usermod 128 |},
default_perm => 1+4+16, # Keep synchronised with the default value of users.perm
default_tags_cat=> 'cont,tech',
- languages => ordhash(grep !/^ *$/, split /[\s\r\n]*([^ ]+) +(.+)/, q{
- ar Arabic
- bg Bulgarian
- ca Catalan
- cs Czech
- da Danish
- de German
- el Greek
- en English
- eo Esperanto
- es Spanish
- fi Finnish
- fr French
- he Hebrew
- hr Croatian
- 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
- ta Tagalog
- th Thai
- tr Turkish
- uk Ukrainian
- vi Vietnamese
- zh Chinese
- }),
producer_types => ordhash(
co => 'Company',
in => 'Individual',
diff --git a/lib/Multi/API.pm b/lib/Multi/API.pm
index aa767fb2..2665ad49 100644
--- a/lib/Multi/API.pm
+++ b/lib/Multi/API.pm
@@ -16,6 +16,7 @@ use Encode 'encode_utf8', 'decode_utf8';
use Crypt::URandom 'urandom';
use Crypt::ScryptKDF 'scrypt_raw';;
use VNDBUtil 'normalize_query', 'norm_ip';
+use VNDB::Types;
use JSON::XS;
use PWLookup;
@@ -1193,7 +1194,7 @@ sub get_filters {
y/%//;
$v = "%$v%";
} elsif(${$o{process}} eq 'lang') {
- return cerr $c, filter => 'Invalid language code', %e if !$VNDB::S{languages}{$v};
+ return cerr $c, filter => 'Invalid language code', %e if !$LANGUAGE{$v};
} elsif(${$o{process}} eq 'plat') {
return cerr $c, filter => 'Invalid platform code', %e if !$VNDB::S{platforms}{$v};
}
diff --git a/lib/Multi/RG.pm b/lib/Multi/RG.pm
index 4234d1c2..d3637c4e 100644
--- a/lib/Multi/RG.pm
+++ b/lib/Multi/RG.pm
@@ -12,6 +12,7 @@ use AnyEvent::Util;
use Encode 'encode_utf8';
use XML::Parser;
use TUWF::XML;
+use VNDB::Types;
my %O = (
@@ -231,7 +232,7 @@ sub gv_prodnode {
q|<TR><TD ALIGN="CENTER"> %s </TD><TD ALIGN="CENTER"> %s </TD></TR>|.
qq|</TABLE>> ]\n|,
$n->{id}, encode_utf8($tooltip), $O{fsize}[2], encode_utf8($name),
- $VNDB::S{languages}{$n->{lang}}, $VNDB::S{producer_types}{$n->{type}};
+ $LANGUAGE{$n->{lang}}, $VNDB::S{producer_types}{$n->{type}};
}
diff --git a/lib/VN3/ElmGen.pm b/lib/VN3/ElmGen.pm
index 2988fa92..743bb1d7 100644
--- a/lib/VN3/ElmGen.pm
+++ b/lib/VN3/ElmGen.pm
@@ -170,7 +170,7 @@ def vnLengths => 'List (Int, String)' => list map tuple($_, string vn
def vnRelations => 'List (String, String)' => list map tuple(string $_, string vn_relation_display $_), vn_relations;
def producerRelations => 'List (String, String)' => list map tuple(string $_, string producer_relation_display $_), keys %PRODUCER_RELATIONS;
def creditType => 'List (String, String)' => list map tuple(string $_, string $CREDIT_TYPE{$_}), keys %CREDIT_TYPE;
-def languages => 'List (String, String)' => list map tuple(string $_, string $LANG{$_}), sort { $LANG{$a} cmp $LANG{$b} } keys %LANG;
+def languages => 'List (String, String)' => list map tuple(string $_, string $LANGUAGE{$_}), sort { $LANGUAGE{$a} cmp $LANGUAGE{$b} } keys %LANGUAGE;
def platforms => 'List (String, String)' => list map tuple(string $_, string $PLATFORMS{$_}), keys %PLATFORMS;
def releaseTypes => 'List String' => list map string($_), release_types;
def producerTypes => 'List (String, String)' => list map tuple(string $_, string $PRODUCER_TYPES{$_}), keys %PRODUCER_TYPES;
diff --git a/lib/VN3/Producer/Page.pm b/lib/VN3/Producer/Page.pm
index 49ddf02b..0e891fa8 100644
--- a/lib/VN3/Producer/Page.pm
+++ b/lib/VN3/Producer/Page.pm
@@ -47,7 +47,7 @@ sub DetailsTable {
Dt 'Language';
Dd sub {
Lang $e->{lang};
- Txt " $LANG{$e->{lang}}";
+ Txt " $LANGUAGE{$e->{lang}}";
}
},
diff --git a/lib/VN3/Release/Page.pm b/lib/VN3/Release/Page.pm
index a17dae11..7563de90 100644
--- a/lib/VN3/Release/Page.pm
+++ b/lib/VN3/Release/Page.pm
@@ -55,7 +55,7 @@ sub DetailsTable {
Dd sub {
Join \&Br, sub {
Lang $_[0]{lang};
- Txt " $LANG{$_[0]{lang}}";
+ Txt " $LANGUAGE{$_[0]{lang}}";
}, @{$e->{lang}};
}
},
diff --git a/lib/VN3/Staff/Page.pm b/lib/VN3/Staff/Page.pm
index 48f06283..2d8cd349 100644
--- a/lib/VN3/Staff/Page.pm
+++ b/lib/VN3/Staff/Page.pm
@@ -44,7 +44,7 @@ sub DetailsTable {
Dt 'Language';
Dd sub {
Lang $e->{lang};
- Txt " $LANG{$e->{lang}}";
+ Txt " $LANGUAGE{$e->{lang}}";
}
},
diff --git a/lib/VN3/Types.pm b/lib/VN3/Types.pm
index a9dfdcae..947ee403 100644
--- a/lib/VN3/Types.pm
+++ b/lib/VN3/Types.pm
@@ -13,7 +13,7 @@ use Exporter 'import';
our @EXPORT = qw/
$UID_RE $VID_RE $RID_RE $SID_RE $CID_RE $PID_RE $IID_RE $DOC_RE
$VREV_RE $RREV_RE $PREV_RE $SREV_RE $CREV_RE $DREV_RE
- %LANG Lang
+ Lang
%PLATFORMS Platform
%MEDIA media_display
%PRODUCER_TYPES
@@ -54,44 +54,6 @@ our $CREV_RE = qr{$CID_RE(?:\.(?<rev>$num))?};
our $DREV_RE = qr{$DOC_RE(?:\.(?<rev>$num))?};
-our %LANG;
-tie %LANG, 'Tie::IxHash', grep !/^ *$/, split /[\s\r\n]*([^ ]+) +(.+)/, q{
- ar Arabic
- bg Bulgarian
- ca Catalan
- cs Czech
- da Danish
- de German
- el Greek
- en English
- eo Esperanto
- es Spanish
- fi Finnish
- fr French
- he Hebrew
- hr Croatian
- 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
- ta Tagalog
- th Thai
- tr Turkish
- uk Ukrainian
- vi Vietnamese
- zh Chinese
-};
-
sub Lang {
Span class => 'lang-badge', uc $_[0];
}
diff --git a/lib/VN3/VN/Page.pm b/lib/VN3/VN/Page.pm
index 81c6491f..0624fb66 100644
--- a/lib/VN3/VN/Page.pm
+++ b/lib/VN3/VN/Page.pm
@@ -38,7 +38,7 @@ sub Top {
Div class => 'vn-header__sep', '';
Txt vn_length_time $vn->{length};
Div class => 'vn-header__sep', '';
- Txt join ', ', map $LANG{$_}, @{$vn->{c_languages}};
+ Txt join ', ', map $LANGUAGE{$_}, @{$vn->{c_languages}};
Debug $vn;
};
};
@@ -218,7 +218,7 @@ sub Releases {
for my $lang (@lang) {
Div class => 'relsm__language', sub {
Lang $lang;
- Txt " $LANG{$lang}";
+ Txt " $LANGUAGE{$lang}";
};
Div class => 'relsm__table', sub {
Div class => 'relsm__rel', sub {
diff --git a/lib/VN3/Validation.pm b/lib/VN3/Validation.pm
index 6f637d2c..20c33e57 100644
--- a/lib/VN3/Validation.pm
+++ b/lib/VN3/Validation.pm
@@ -28,7 +28,7 @@ TUWF::set custom_validations => {
producer_relation => { enum => \%PRODUCER_RELATIONS },
staff_role => { enum => \%CREDIT_TYPE },
char_role => { enum => \%CHAR_ROLES },
- language => { enum => \%LANG },
+ language => { enum => \%LANGUAGE },
platform => { enum => \%PLATFORMS },
medium => { enum => \%MEDIA },
resolution => { enum => \%RESOLUTIONS },
diff --git a/lib/VNDB/Handler/Misc.pm b/lib/VNDB/Handler/Misc.pm
index 771c9d83..366b9429 100644
--- a/lib/VNDB/Handler/Misc.pm
+++ b/lib/VNDB/Handler/Misc.pm
@@ -6,6 +6,7 @@ use strict;
use warnings;
use TUWF ':html', ':xml', 'uri_escape';
use VNDB::Func;
+use VNDB::Types;
TUWF::register(
@@ -158,7 +159,7 @@ sub homepage {
lit fmtdatestr $_->{released};
txt ' ';
cssicon $_, $self->{platforms}{$_} for (@{$_->{platforms}});
- cssicon "lang $_", $self->{languages}{$_} for (@{$_->{languages}});
+ cssicon "lang $_", $LANGUAGE{$_} for (@{$_->{languages}});
txt ' ';
a href => "/r$_->{id}", title => $_->{original}||$_->{title}, shorten $_->{title}, 30;
end;
@@ -178,7 +179,7 @@ sub homepage {
lit fmtdatestr $_->{released};
txt ' ';
cssicon $_, $self->{platforms}{$_} for (@{$_->{platforms}});
- cssicon "lang $_", $self->{languages}{$_} for (@{$_->{languages}});
+ cssicon "lang $_", $LANGUAGE{$_} for (@{$_->{languages}});
txt ' ';
a href => "/r$_->{id}", title => $_->{original}||$_->{title}, shorten $_->{title}, 30;
end;
diff --git a/lib/VNDB/Handler/Producers.pm b/lib/VNDB/Handler/Producers.pm
index e8b0f43d..cb5ce4cc 100644
--- a/lib/VNDB/Handler/Producers.pm
+++ b/lib/VNDB/Handler/Producers.pm
@@ -5,6 +5,7 @@ use strict;
use warnings;
use TUWF ':html', ':xml', 'xml_escape', 'html_escape';
use VNDB::Func;
+use VNDB::Types;
TUWF::register(
@@ -66,7 +67,7 @@ sub page {
[ name => 'Name (romaji)', diff => 1 ],
[ original => 'Original name', diff => 1 ],
[ alias => 'Aliases', diff => qr/[ ,\n\.]/ ],
- [ lang => 'Language', serialize => sub { "$_[0] ($self->{languages}{$_[0]})" } ],
+ [ lang => 'Language', serialize => sub { "$_[0] ($LANGUAGE{$_[0]})" } ],
[ website => 'Website', diff => 1 ],
[ l_wp => 'Wikipedia link',htmlize => sub {
$_[0] ? sprintf '<a href="http://en.wikipedia.org/wiki/%s">%1$s</a>', xml_escape $_[0] : '[empty]'
@@ -87,7 +88,7 @@ sub page {
h1 $p->{name};
h2 class => 'alttitle', $p->{original} if $p->{original};
p class => 'center';
- txt "$self->{languages}{$p->{lang}} $self->{producer_types}{$p->{type}}";
+ txt "$LANGUAGE{$p->{lang}} $self->{producer_types}{$p->{type}}";
if($p->{alias}) {
(my $alias = $p->{alias}) =~ s/\n/, /g;
br;
@@ -176,7 +177,7 @@ sub _releases {
next if $_ eq 'oth';
cssicon $_, $self->{platforms}{$_};
}
- cssicon "lang $_", $self->{languages}{$_} for (@{$rel->{languages}});
+ cssicon "lang $_", $LANGUAGE{$_} for (@{$rel->{languages}});
cssicon "rt$rel->{type}", $rel->{type};
end;
td class => 'tc4';
@@ -284,7 +285,7 @@ sub edit {
{ post => 'name', maxlength => 200 },
{ post => 'original', required => 0, maxlength => 200, default => '' },
{ post => 'alias', required => 0, maxlength => 500, default => '' },
- { post => 'lang', required => !$nosubmit, enum => [ keys %{$self->{languages}} ] },
+ { post => 'lang', required => !$nosubmit, enum => [ keys %LANGUAGE ] },
{ post => 'website', required => 0, maxlength => 250, default => '', template => 'weburl' },
{ post => 'l_wikidata', required => 0, template => 'wikidata' },
{ post => 'desc', required => 0, maxlength => 5000, default => '' },
@@ -340,7 +341,7 @@ sub edit {
[ textarea => short => 'alias', name => 'Aliases', rows => 4 ],
[ static => content => '(Un)official aliases, separated by a newline.' ],
[ select => name => 'Primary language', short => 'lang',
- options => [ map [ $_, "$_ ($self->{languages}{$_})" ], keys %{$self->{languages}} ] ],
+ options => [ map [ $_, "$_ ($LANGUAGE{$_})" ], keys %LANGUAGE ] ],
[ input => name => 'Website', short => 'website' ],
[ input => short => 'l_wikidata',name => 'Wikidata ID',
value => $frm->{l_wikidata} ? "Q$frm->{l_wikidata}" : '',
@@ -450,7 +451,7 @@ sub list {
ul;
for ($perlist*$c..($perlist*($c+1))-1) {
li;
- cssicon 'lang '.$list->[$_]{lang}, $self->{languages}{$list->[$_]{lang}};
+ cssicon 'lang '.$list->[$_]{lang}, $LANGUAGE{$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 db2daea1..b3ef3014 100644
--- a/lib/VNDB/Handler/Releases.pm
+++ b/lib/VNDB/Handler/Releases.pm
@@ -5,6 +5,7 @@ use strict;
use warnings;
use TUWF ':html', ':xml', 'uri_escape', 'xml_escape';
use VNDB::Func;
+use VNDB::Types;
use Exporter 'import';
our @EXPORT = ('releaseExtLinks');
@@ -60,7 +61,7 @@ sub page {
[ original => 'Original title', diff => 1 ],
[ gtin => 'JAN/UPC/EAN', serialize => sub { $_[0]||'[empty]' } ],
[ catalog => 'Catalog number', serialize => sub { $_[0]||'[empty]' } ],
- [ languages => 'Language', join => ', ', split => sub { map $self->{languages}{$_}, @{$_[0]} } ],
+ [ languages => 'Language', join => ', ', split => sub { map $LANGUAGE{$_}, @{$_[0]} } ],
[ website => 'Website' ],
[ l_egs => 'ErogameScape', htmlize => sub { $_[0] ? sprintf '<a href="https://erogamescape.dyndns.org/~ap2/ero/toukei_kaiseki/game.php?game=%d">%1$d</a>', $_[0] : '[empty]' } ],
[ l_erotrail => 'ErogeTrailers', htmlize => sub { $_[0] ? sprintf '<a href="http://erogetrailers.com/soft/%d">%1$d</a>', $_[0] : '[empty]' } ],
@@ -153,8 +154,8 @@ sub _infotable {
td 'Language';
td;
for (@{$r->{languages}}) {
- cssicon "lang $_", $self->{languages}{$_};
- txt ' '.$self->{languages}{$_};
+ cssicon "lang $_", $LANGUAGE{$_};
+ txt ' '.$LANGUAGE{$_};
br if $_ ne $r->{languages}[$#{$r->{languages}}];
}
end;
@@ -360,7 +361,7 @@ 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 => [ keys %{$self->{languages}} ] },
+ { post => 'languages', multi => 1, enum => [ keys %LANGUAGE ] },
{ post => 'website', required => 0, default => '', maxlength => 250, template => 'weburl' },
{ post => 'l_steam', required => 0, default => 0, template => 'uint' },
{ post => 'l_dlsite', required => 0, default => '', regex => [ qr/^[VR]J[0-9]{6}$/, 'Invalid DLsite ID' ] },
@@ -486,7 +487,7 @@ sub _form {
[ input => short => 'original', name => 'Original title', width => 450 ],
[ static => content => 'The original title of this release, leave blank if it already is in the Latin alphabet.' ],
[ select => short => 'languages', name => 'Language(s)', multi => 1,
- options => [ map [ $_, "$_ ($self->{languages}{$_})" ], keys %{$self->{languages}} ] ],
+ options => [ map [ $_, "$_ ($LANGUAGE{$_})" ], keys %LANGUAGE ] ],
[ input => short => 'gtin', name => 'JAN/UPC/EAN' ],
[ input => short => 'catalog', name => 'Catalog number' ],
[ input => short => 'website', name => 'Official website' ],
@@ -679,7 +680,7 @@ sub browse {
td class => 'tc2', $l->{minage} < 0 ? '' : minage $l->{minage};
td class => 'tc3';
$_ ne 'oth' && cssicon $_, $self->{platforms}{$_} for (@{$l->{platforms}});
- cssicon "lang $_", $self->{languages}{$_} for (@{$l->{languages}});
+ cssicon "lang $_", $LANGUAGE{$_} for (@{$l->{languages}});
cssicon "rt$l->{type}", $l->{type};
end;
td class => 'tc4';
@@ -712,7 +713,7 @@ sub _fil_compat {
my $self = shift;
my %c;
my $f = $self->formValidate(
- { get => 'ln', required => 0, multi => 1, default => '', enum => [ keys %{$self->{languages}} ] },
+ { get => 'ln', required => 0, multi => 1, default => '', enum => [ keys %LANGUAGE ] },
{ 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}} ] },
diff --git a/lib/VNDB/Handler/Staff.pm b/lib/VNDB/Handler/Staff.pm
index b3d27b91..ceaf56bb 100644
--- a/lib/VNDB/Handler/Staff.pm
+++ b/lib/VNDB/Handler/Staff.pm
@@ -43,7 +43,7 @@ sub page {
[ name => 'Name (romaji)', diff => 1 ],
[ original => 'Original name', diff => 1 ],
[ gender => 'Gender', serialize => sub { $self->{genders}{$_[0]} } ],
- [ lang => 'Language', serialize => sub { "$_[0] ($self->{languages}{$_[0]})" } ],
+ [ lang => 'Language', serialize => sub { "$_[0] ($LANGUAGE{$_[0]})" } ],
[ l_site => 'Official page', diff => 1 ],
[ l_wp => 'Wikipedia link', htmlize => sub { $_[0] ? sprintf '<a href="http://en.wikipedia.org/wiki/%s">%1$s</a>', xml_escape $_[0] : '[empty]' }],
[ l_wikidata=> 'Wikidata ID', htmlize => sub { $_[0] ? sprintf '<a href="https://www.wikidata.org/wiki/Q%d">Q%1$d</a>', $_[0] : '[empty]' } ],
@@ -75,7 +75,7 @@ sub page {
end;
Tr;
td class => 'key', 'Language';
- td $self->{languages}{$s->{lang}};
+ td $LANGUAGE{$s->{lang}};
end;
if(@{$s->{aliases}}) {
Tr;
@@ -206,7 +206,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 => [ keys %{$self->{languages}} ] },
+ { post => 'lang', enum => [ keys %LANGUAGE ] },
{ post => 'l_site', required => 0, template => 'weburl', maxlength => 250, default => '' },
{ post => 'l_wikidata', required => 0, template => 'wikidata' },
{ post => 'l_twitter', required => 0, maxlength => 16, default => '', regex => [ qr/^\S+$/, 'Invalid twitter username' ] },
@@ -280,7 +280,7 @@ sub edit {
[ select => name => 'Gender',short => 'gender', options => [
map [ $_, $self->{genders}{$_} ], qw(unknown m f) ] ],
[ select => name => 'Primary language', short => 'lang',
- options => [ map [ $_, "$_ ($self->{languages}{$_})" ], keys %{$self->{languages}} ] ],
+ options => [ map [ $_, "$_ ($LANGUAGE{$_})" ], keys %LANGUAGE ] ],
[ input => name => 'Official page', short => 'l_site' ],
[ input => short => 'l_wikidata',name => 'Wikidata ID',
value => $frm->{l_wikidata} ? "Q$frm->{l_wikidata}" : '',
@@ -355,7 +355,7 @@ sub list {
for ($perlist*$c..($perlist*($c+1))-1) {
li;
my $gender = $list->[$_]{gender};
- cssicon 'lang '.$list->[$_]{lang}, $self->{languages}{$list->[$_]{lang}};
+ cssicon 'lang '.$list->[$_]{lang}, $LANGUAGE{$list->[$_]{lang}};
a href => "/s$list->[$_]{id}",
title => $list->[$_]{original}, $list->[$_]{name};
end;
diff --git a/lib/VNDB/Handler/VNBrowse.pm b/lib/VNDB/Handler/VNBrowse.pm
index 554541a7..2049e455 100644
--- a/lib/VNDB/Handler/VNBrowse.pm
+++ b/lib/VNDB/Handler/VNBrowse.pm
@@ -5,6 +5,7 @@ use strict;
use warnings;
use TUWF ':html', 'uri_escape';
use VNDB::Func;
+use VNDB::Types;
TUWF::register(
@@ -131,7 +132,7 @@ sub _fil_compat {
my $self = shift;
my %c;
my $f = $self->formValidate(
- { get => 'ln', required => 0, multi => 1, enum => [ keys %{$self->{languages}} ], default => '' },
+ { get => 'ln', required => 0, multi => 1, enum => [ keys %LANGUAGE ], 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] },
);
diff --git a/lib/VNDB/Handler/VNPage.pm b/lib/VNDB/Handler/VNPage.pm
index 3579a9ff..6a438341 100644
--- a/lib/VNDB/Handler/VNPage.pm
+++ b/lib/VNDB/Handler/VNPage.pm
@@ -78,7 +78,7 @@ my @rel_cols = (
has_data => sub { !!@{$_[0]{languages}} },
draw => sub {
for(@{$_[0]{languages}}) {
- cssicon "lang $_", $TUWF::OBJ->{languages}{$_};
+ cssicon "lang $_", $LANGUAGE{$_};
br if $_ ne $_[0]{languages}[$#{$_[0]{languages}}];
}
},
@@ -199,7 +199,7 @@ sub releases {
{ 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', keys %{$self->{platforms}} ] },
- { get => 'lang', required => 0, default => 'all', enum => [ 'all', keys %{$self->{languages}} ] },
+ { get => 'lang', required => 0, default => 'all', enum => [ 'all', keys %LANGUAGE ] },
);
return $self->resNotFound if $f->{_err};
@@ -261,7 +261,7 @@ sub _releases_buttons {
end 'p';
};
$plat_lang_draw->('platforms', 'os', $self->{platforms}, '') if $f->{pla};
- $plat_lang_draw->('languages', 'lang',$self->{languages}, 'lang') if $f->{lan};
+ $plat_lang_draw->('languages', 'lang',\%LANGUAGE, 'lang') if $f->{lan};
}
@@ -626,7 +626,7 @@ sub _producers {
my %p = map $_->{publisher} ? ($_->{id} => $_) : (), map @{$_->{producers}}, grep grep($_ eq $l, @{$_->{languages}}), @$r;
my @p = sort { $a->{name} cmp $b->{name} } values %p;
next if !@p;
- cssicon "lang $l", $self->{languages}{$l};
+ cssicon "lang $l", $LANGUAGE{$l};
for (@p) {
a href => "/p$_->{id}", title => $_->{original}||$_->{name}, shorten $_->{name}, 30;
txt ' & ' if $_ != $p[$#p];
@@ -807,8 +807,8 @@ sub _releases {
for my $l (@lang) {
Tr class => 'lang';
td colspan => 7;
- cssicon "lang $l", $self->{languages}{$l};
- txt $self->{languages}{$l};
+ cssicon "lang $l", $LANGUAGE{$l};
+ txt $LANGUAGE{$l};
end;
end;
for my $rel (grep grep($_ eq $l, @{$_->{languages}}), @$r) {
@@ -927,7 +927,7 @@ sub _screenshots {
my @scr = grep $_->{rid} && $rel->{id} == $_->{rid}, @{$v->{screenshots}};
next if !@scr;
p class => 'rel';
- cssicon "lang $_", $self->{languages}{$_} for (@{$rel->{languages}});
+ cssicon "lang $_", $LANGUAGE{$_} for (@{$rel->{languages}});
cssicon $_, $TUWF::OBJ->{platforms}{$_} for (@{$rel->{platforms}});
a href => "/r$rel->{id}", $rel->{title};
end;
diff --git a/lib/VNDB/Types.pm b/lib/VNDB/Types.pm
index c9217307..ee929063 100644
--- a/lib/VNDB/Types.pm
+++ b/lib/VNDB/Types.pm
@@ -22,6 +22,45 @@ sub fun($&) {
+# SQL: ENUM language
+hash LANGUAGE =>
+ ar => 'Arabic',
+ bg => 'Bulgarian',
+ ca => 'Catalan',
+ cs => 'Czech',
+ da => 'Danish',
+ de => 'German',
+ el => 'Greek',
+ en => 'English',
+ eo => 'Esperanto',
+ es => 'Spanish',
+ fi => 'Finnish',
+ fr => 'French',
+ he => 'Hebrew',
+ hr => 'Croatian',
+ 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',
+ ta => 'Tagalog',
+ th => 'Thai',
+ tr => 'Turkish',
+ uk => 'Ukrainian',
+ vi => 'Vietnamese',
+ zh => 'Chinese';
+
+
+
# SQL: ENUM credit_type
hash CREDIT_TYPE =>
scenario => 'Scenario',
diff --git a/lib/VNDB/Util/BrowseHTML.pm b/lib/VNDB/Util/BrowseHTML.pm
index c3115017..749f69f8 100644
--- a/lib/VNDB/Util/BrowseHTML.pm
+++ b/lib/VNDB/Util/BrowseHTML.pm
@@ -6,6 +6,7 @@ use warnings;
use TUWF ':html', 'xml_escape';
use Exporter 'import';
use VNDB::Func;
+use VNDB::Types;
use POSIX 'ceil';
@@ -202,7 +203,7 @@ sub htmlBrowseVN {
for (sort @{$l->{c_platforms}});
end;
td class => 'tc3';
- cssicon "lang $_", $self->{languages}{$_}
+ cssicon "lang $_", $LANGUAGE{$_}
for (reverse sort @{$l->{c_languages}});
end;
td class => 'tc4';
diff --git a/util/jsgen.pl b/util/jsgen.pl
index 6829f719..b8332829 100755
--- a/util/jsgen.pl
+++ b/util/jsgen.pl
@@ -39,7 +39,7 @@ sub vars {
rlist_status => $S{rlist_status},
cookie_prefix => $O{cookie_prefix},
age_ratings => [ map [ $_, $_ == -1 ? 'Unknown' : $_ == 0 ? 'All ages' : "$_+" ], @{$S{age_ratings}} ],
- languages => [ map [ $_, $S{languages}{$_} ], keys %{$S{languages}} ],
+ languages => [ map [ $_, $LANGUAGE{$_} ], keys %LANGUAGE ],
platforms => [ map [ $_, $S{platforms}{$_} ], keys %{$S{platforms}} ],
char_roles => [ map [ $_, $S{char_roles}{$_}[0] ], keys %{$S{char_roles}} ],
media => [ map [ $_, $S{media}{$_}[1], $S{media}{$_}[0] ], keys %{$S{media}} ],