diff options
author | Yorhel <git@yorhel.nl> | 2016-01-17 11:32:03 +0100 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2016-01-17 11:39:53 +0100 |
commit | 38a4c36b21b1979a64cb915a80167fb7f8cadb9e (patch) | |
tree | 80f8c4fe110ddffa8a1aaf8d80e774544d38a533 /lib | |
parent | b14f137dc5613472eb68ffea2bb76abc3f7172b6 (diff) |
L10N: Intern VN/producer relations + update relation graphs
Now that graphviz knows the actual strings, it has a better opportunity
to create better graphs.
(Most of them still look messy tho)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Multi/RG.pm | 23 | ||||
-rw-r--r-- | lib/VNDB/Handler/Producers.pm | 10 | ||||
-rw-r--r-- | lib/VNDB/Handler/VNEdit.pm | 2 | ||||
-rw-r--r-- | lib/VNDB/Handler/VNPage.pm | 6 |
4 files changed, 19 insertions, 22 deletions
diff --git a/lib/Multi/RG.pm b/lib/Multi/RG.pm index eade569a..401b5e70 100644 --- a/lib/Multi/RG.pm +++ b/lib/Multi/RG.pm @@ -181,11 +181,12 @@ sub gv_vnrels { ($_->[0], $_->[1]) = ($_->[1], $_->[0]); $_->[2] = $VNDB::S{vn_relations}{$_->[2]}[1]; } - my $rev = $VNDB::S{vn_relations}{$_->[2]}[1]; + my $rel = $VNDB::S{vn_relations}{$_->[2]}[2]; + my $rev = $VNDB::S{vn_relations}{ $VNDB::S{vn_relations}{$_->[2]}[1] }[2]; my $style = $_->[3] ? '' : ', style="dotted"'; - my $label = $rev ne $_->[2] - ? qq|headlabel = "\$____vnrel_$_->[2]____\$" taillabel = "\$____vnrel_${rev}____\$" $style| - : qq|label = "\$____vnrel_$_->[2]____\$" $style|; + my $label = $rev ne $rel + ? qq|headlabel = "$rel" taillabel = "${rev}" $style| + : qq|label = "$rel" $style|; $r .= qq|\tv$$_[1] -- v$$_[0] [ $label ]\n|; } $r; @@ -209,9 +210,10 @@ sub gv_prodnode { qq|\tp%d [ id = "node_p%1\$d", URL = "/p%1\$d", tooltip = "%s", label=<|. q|<TABLE CELLSPACING="0" CELLPADDING="1" BORDER="0" CELLBORDER="1" BGCOLOR="#222222">|. q|<TR><TD COLSPAN="2" ALIGN="CENTER" CELLPADDING="2"><FONT POINT-SIZE="%d"> %s </FONT></TD></TR>|. - q|<TR><TD ALIGN="CENTER"> $_lang_%s_$ </TD><TD ALIGN="CENTER"> $_ptype_%s_$ </TD></TR>|. + 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), $n->{lang}, $n->{type}; + $n->{id}, encode_utf8($tooltip), $O{fsize}[2], encode_utf8($name), + $VNDB::S{languages}{$n->{lang}}, $VNDB::S{producer_types}{$n->{type}}; } @@ -224,10 +226,11 @@ sub gv_prodrels { my $p1 = $prods->{$1}; my $p2 = $prods->{$2}; - my $rev = $VNDB::S{prod_relations}{$rels->{$_}[0]}[1]; - my $label = $rev ne $rels->{$_}[0] - ? qq|headlabel = "\$____prodrel_${rev}____\$", taillabel = "\$____prodrel_$rels->{$_}[0]____\$"| - : qq|label = "\$____prodrel_$rels->{$_}[0]____\$"|; + my $rel = $VNDB::S{prod_relations}{$rels->{$_}[0]}[2]; + my $rev = $VNDB::S{prod_relations}{ $VNDB::S{prod_relations}{$rels->{$_}[0]}[1] }[2]; + my $label = $rev ne $rel + ? qq|headlabel = "$rev", taillabel = "$rel"| + : qq|label = "$rel"|; $r .= qq|\tp$p1->{id} -- p$p2->{id} [ $label ]\n|; } $r; diff --git a/lib/VNDB/Handler/Producers.pm b/lib/VNDB/Handler/Producers.pm index cf534b3e..29c68d2d 100644 --- a/lib/VNDB/Handler/Producers.pm +++ b/lib/VNDB/Handler/Producers.pm @@ -27,10 +27,6 @@ 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-]+)_\$/$self->{languages}{$1}/eg; - $p->{svg} =~ s/\$_ptype_([a-z]+)_\$/$self->{producer_types}{$1}/eg; div class => 'mainbox'; h1 $title; @@ -72,7 +68,7 @@ sub page { [ desc => diff => qr/[ ,\n\.]/ ], [ relations => join => '<br />', split => sub { my @r = map sprintf('%s: <a href="/p%d" title="%s">%s</a>', - mt("_prodrel_$_->{relation}"), $_->{id}, xml_escape($_->{original}||$_->{name}), xml_escape shorten $_->{name}, 40 + $self->{prod_relations}{$_->{relation}}[2], $_->{id}, xml_escape($_->{original}||$_->{name}), xml_escape shorten $_->{name}, 40 ), sort { $a->{id} <=> $b->{id} } @{$_[0]}; return @r ? @r : (mt '_revision_empty'); }], @@ -105,7 +101,7 @@ sub page { p class => 'center'; br; for my $r (sort { $self->{prod_relations}{$a}[0] <=> $self->{prod_relations}{$b}[0] } keys %rel) { - txt mt("_prodrel_$r").': '; + txt $self->{prod_relations}{$r}[2].': '; for (@{$rel{$r}}) { a href => "/p$_->{id}", title => $_->{original}||$_->{name}, shorten $_->{name}, 40; txt ', ' if $_ ne $rel{$r}[$#{$rel{$r}}]; @@ -301,7 +297,7 @@ sub edit { end; td class => 'tc_rel'; Select; - option value => $_, mt "_prodrel_$_" + option value => $_, $self->{prod_relations}{$_}[2] for (sort { $self->{prod_relations}{$a}[0] <=> $self->{prod_relations}{$b}[0] } keys %{$self->{prod_relations}}); end; end; diff --git a/lib/VNDB/Handler/VNEdit.pm b/lib/VNDB/Handler/VNEdit.pm index 3d7b9db4..854bbf46 100644 --- a/lib/VNDB/Handler/VNEdit.pm +++ b/lib/VNDB/Handler/VNEdit.pm @@ -379,7 +379,7 @@ sub _form { input type => 'checkbox', id => 'official', checked => 'checked'; label for => 'official', mt '_vnedit_rel_official'; Select; - option value => $_, mt "_vnrel_$_" + option value => $_, $self->{vn_relations}{$_}[2] for (sort { $self->{vn_relations}{$a}[0] <=> $self->{vn_relations}{$b}[0] } keys %{$self->{vn_relations}}); end; txt ' '.mt '_vnedit_rel_of'; diff --git a/lib/VNDB/Handler/VNPage.pm b/lib/VNDB/Handler/VNPage.pm index c5635f1d..50f21071 100644 --- a/lib/VNDB/Handler/VNPage.pm +++ b/lib/VNDB/Handler/VNPage.pm @@ -33,8 +33,6 @@ 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'; h1 $title; @@ -534,7 +532,7 @@ sub _revision { [ relations => join => '<br />', split => sub { my @r = map sprintf('[%s] %s: <a href="/v%d" title="%s">%s</a>', mt($_->{official} ? '_vndiff_rel_official' : '_vndiff_rel_unofficial'), - mt("_vnrel_$_->{relation}"), $_->{id}, xml_escape($_->{original}||$_->{title}), xml_escape shorten $_->{title}, 40 + $self->{vn_relations}{$_->{relation}}[2], $_->{id}, xml_escape($_->{original}||$_->{title}), xml_escape shorten $_->{title}, 40 ), sort { $a->{id} <=> $b->{id} } @{$_[0]}; return @r ? @r : (mt '_revision_empty'); }], @@ -617,7 +615,7 @@ sub _relations { td class => 'relations'; dl; for(sort keys %rel) { - dt mt "_vnrel_$_"; + dt $self->{vn_relations}{$_}[2]; dd; for (@{$rel{$_}}) { b class => 'grayedout', mt('_vnpage_relations_unofficial').' ' if !$_->{official}; |