});
} or Abort('Database error', 501, $@);
+my %lang = (
+ nld => ["\N{REGIONAL INDICATOR SYMBOL LETTER N}\N{REGIONAL INDICATOR SYMBOL LETTER L}", 'dutch'],
+ eng => ["\N{REGIONAL INDICATOR SYMBOL LETTER G}\N{REGIONAL INDICATOR SYMBOL LETTER B}", 'english'],
+ epo => ['<span style="color:green">★</span>', 'esperanto'],
+);
my @wordcols = pairkeys
my %wordcol = (
- lang => 'Language',
+ lang => {-label => 'Language', -select => {
+ map { $_ => "@{$lang{$_}}" } keys %lang
+ }},
cat => [{-label => 'Category'}, 'ref'],
ref => {-label => 'Reference'},
prio => [
source => 'Image',
thumb => 'Convert options',
);
-my %langflag = (
- nld => "\N{REGIONAL INDICATOR SYMBOL LETTER N}\N{REGIONAL INDICATOR SYMBOL LETTER L}",
- eng => "\N{REGIONAL INDICATOR SYMBOL LETTER G}\N{REGIONAL INDICATOR SYMBOL LETTER B}",
- epo => '<span style="color:green">★</span>',
-);
my ($find) = map {{id => $_}} $fields{id} || $Request || ();
my $row;
$html .= qq( $_="$attr->{$_}") for sort grep {!/^-/} keys %{$attr // {}};
if (my $options = $attr->{-select}) {
+ $options = { map {$_ => $options->[$_]} 0 .. $#{$options} }
+ if ref $options eq 'ARRAY';
+ $options->{$val} //= "unknown ($val)"; # preserve current
return (
sprintf('<select id="%s" name="%1$s">', $col),
(map { sprintf('<option value="%s"%s>%s</option>',
- $_, $val eq $_ && ' selected', $options->[$_]
- ) } 0 .. $#{$options}),
+ $_, $val eq $_ && ' selected', $options->{$_}
+ ) } sort keys %{$options}),
'</select>',
);
}
my $children = $db->select(word => '*', {ref => $row->{id}}, 'lang, id');
printf '<li><label>%s</label><div><ul class="inline">', 'Translations';
while (my $row = $children->hash) {
- printf '<li><label for="%s">%s</label> <a id="%1$s" href="%s">%s</a></li>',
- "trans-$row->{lang}", $langflag{$row->{lang}},
- "/writer/$row->{id}", Entity($row->{form});
+ printf(
+ '<li><label for="%1$s" title="%5$s">%4$s</label>' .
+ ' <a id="%s" href="%s">%s</a></li>',
+ "trans-$row->{lang}", "/writer/$row->{id}", Entity($row->{form}),
+ @{$lang{ $row->{lang} }}, # flag, name
+ );
}
say '</ul></div></li>';
}