summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2009-09-06 16:00:37 +0200
committerYorhel <git@yorhel.nl>2009-09-06 16:00:37 +0200
commit5323a0c62ad471b1f2c4a77e6fc0e890792e9399 (patch)
tree31cd38be16f8833a755e5c067f1520f4704e3514 /lib
parent74bc0733e290d1f4b9726f7fbb46865789bcc7cb (diff)
L10N: Converted Util::FormHTML
Removed the idea mapping field names to readable strings, it was never really a clean solution. The messages did become less readable now, but oh well...
Diffstat (limited to 'lib')
-rw-r--r--lib/VNDB/Util/FormHTML.pm90
1 files changed, 14 insertions, 76 deletions
diff --git a/lib/VNDB/Util/FormHTML.pm b/lib/VNDB/Util/FormHTML.pm
index 7e3b6f67..8b46daae 100644
--- a/lib/VNDB/Util/FormHTML.pm
+++ b/lib/VNDB/Util/FormHTML.pm
@@ -6,58 +6,11 @@ use warnings;
use YAWF ':html';
use Exporter 'import';
use POSIX 'strftime';
+use VNDB::Func;
our @EXPORT = qw| htmlFormError htmlFormPart htmlForm |;
-# form error messages
-my %formerr_names = (
- alias => 'Aliases',
- anime => 'Anime',
- desc => 'Description',
- description => 'Description',
- editsum => 'Edit summary',
- gtin => 'JAN/EAN/UPC',
- lang => 'Language',
- language => 'Language',
- length => 'Length',
- l_wp => 'Wikipedia link',
- l_encubed => 'Novelnews link',
- l_renai => 'Renai.us link',
- l_vnn => 'V-N.net link',
- mail => 'Email',
- media => 'Media',
- minage => 'Age rating',
- msg => 'Message',
- name => 'Name',
- notes => 'Notes',
- original => 'Original',
- platforms => 'Platforms',
- producers => 'Producers',
- released => 'Release date',
- boards => 'Boards',
- title => 'Title',
- type => 'Type',
- usrname => 'Username',
- usrpass => 'Password',
- usrpass2 => 'Password (confirm)',
- vn => 'Visual novels',
- website => 'Website',
-);
-my %formerr_exeptions = (
- login_failed => 'Invalid username or password',
- nomail => 'No user found with that email address',
- passmatch => 'Passwords do not match',
- usrexists => 'Someone already has this username, please choose something else',
- mailexists => 'Someone already registered with that email address',
- noimage => 'Image must be in JPEG or PNG format',
- toolarge => 'Image is too large, only 500kB allowed',
- oneaday => 'You can only register one account from the same IP within 24 hours',
- nochanges => 'No changes, please don\'t create an entry that is fully -identical- to another',
- doublepost => 'Please wait 30 seconds before making another post',
-);
-
-
# Displays friendly error message when form validation failed
# Argument is the return value of formValidate, and an optional
# argument indicating whether we should create a special mainbox
@@ -67,40 +20,25 @@ sub htmlFormError {
return if !$frm->{_err};
if($mainbox) {
div class => 'mainbox';
- h1 'Error';
+ h1 mt '_formerr_title';
}
div class => 'warning';
- h2 'Form could not be sent:';
+ h2 mt '_formerr_subtitle';
ul;
for my $e (@{$frm->{_err}}) {
if(!ref $e) {
- li $formerr_exeptions{$e};
+ li mt '_formerr_e_'.$e;
next;
}
my($field, $type, $rule) = @$e;
- $field = $formerr_names{$field}||$field;
- li sprintf '%s is a required field!', $field if $type eq 'required';
- li sprintf '%s should have at least %d characters', $field, $rule if $type eq 'minlength';
- li sprintf '%s: only %d characters allowed', $field, $rule if $type eq 'maxlength';
- li sprintf '%s must be one of the following: %s', $field, join ', ', @$rule if $type eq 'enum';
- li sprintf 'Wrong board: %s', $rule if $type eq 'wrongboard';
- if($type eq 'tagexists') {
- li;
- lit $rule->{state} != 1 ? qq|Tag <a href="/g$rule->{id}">$rule->{name}</a> already exists!|
- : qq|A tag <a href="/g$rule->{id}">with the same name</a> has been deleted in the past,|
- .qq| please use <a href="/t/db">the discussion board</a> if you want it to be re-added.|;
- end;
- }
+ li mt '_formerr_required', $field if $type eq 'required';
+ li mt '_formerr_minlength', $field, $rule if $type eq 'minlength';
+ li mt '_formerr_maxlength', $field, $rule if $type eq 'maxlength';
+ li mt '_formerr_enum', $field, join ', ', @$rule if $type eq 'enum';
+ li mt '_formerr_wrongboard', $rule if $type eq 'wrongboard';
+ li mt '_formerr_tagexists', "/g$rule->{id}", $rule->{name} if $type eq 'tagexists';
li $rule->[1] if $type eq 'func' || $type eq 'regex';
- if($type eq 'template') {
- li sprintf
- $rule eq 'mail' ? 'Invalid email address' :
- $rule eq 'url' ? '%s: Invalid URL' :
- $rule eq 'asciiprint' ? '%s may only contain ASCII characters' :
- $rule eq 'int' ? '%s: Not a valid number' :
- $rule eq 'pname' ? '%s can only contain lowercase alphanumberic characters and a hyphen, and must start with a character' : '',
- $field;
- }
+ li mt "_formerr_tpl_$rule", $field if $type eq 'template';
}
end;
end;
@@ -251,7 +189,7 @@ sub htmlForm {
end;
}
li class => 'left';
- a href => '#all', id => 'jt_sel_all', 'All items';
+ a href => '#all', id => 'jt_sel_all', mt '_form_tab_all';
end;
end;
}
@@ -279,13 +217,13 @@ sub htmlForm {
(my $txt = $options->{frm}{editsum}||'') =~ s/&/&amp;/;
$txt =~ s/</&lt;/;
$txt =~ s/>/&gt;/;
- h2 'Edit summary';
+ h2 mt '_form_editsum';
textarea name => 'editsum', id => 'editsum', rows => 4, cols => 50;
lit $txt;
end;
br;
}
- input type => 'submit', value => 'Submit', class => 'submit';
+ input type => 'submit', value => mt('_form_submit'), class => 'submit';
end;
end;
}