From 5323a0c62ad471b1f2c4a77e6fc0e890792e9399 Mon Sep 17 00:00:00 2001 From: Yorhel Date: Sun, 6 Sep 2009 16:00:37 +0200 Subject: 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... --- data/lang.txt | 107 ++++++++++++++++++++++++++++++++++++++++++++++ lib/VNDB/Util/FormHTML.pm | 90 ++++++-------------------------------- 2 files changed, 121 insertions(+), 76 deletions(-) diff --git a/data/lang.txt b/data/lang.txt index 7c700aa7..9277f334 100644 --- a/data/lang.txt +++ b/data/lang.txt @@ -427,6 +427,113 @@ en : masterpiece ru*: +# Form messages + +:_formerr_e_login_failed +en : Invalid username or password +ru*: + +:_formerr_e_nomail +en : No user found with that email address +ru*: + +:_formerr_e_passmatch +en : Passwords do not match +ru*: + +:_formerr_e_usrexists +en : Someone already has this username, please choose something else +ru*: + +:_formerr_e_mailexists +en : Someone already registered with that email address +ru*: + +:_formerr_e_noimage +en : Image must be in JPEG or PNG format +ru*: + +:_formerr_e_toolarge +en : Image is too large, only 500kB allowed +ru*: + +:_formerr_e_oneaday +en : You can only register one account from the same IP within 24 hours +ru*: + +:_formerr_e_nochanges +en : No changes, please don't create an entry that is fully identical to another +ru*: + +:_formerr_e_doublepost +en : Please wait 30 seconds before making another post +ru*: + +:_formerr_title +en : Error +ru*: + +:_formerr_subtitle +en : Form could not be sent: +ru*: + +:_formerr_required +en : [_1] is a required field! +ru*: + +:_formerr_minlength +en : [_1]: should have at least [_2] characters +ru*: + +:_formerr_maxlength +en : [_1]: only [_2] characters allowed +ru*: + +:_formerr_enum +en : [_1] must be one of the following: [_2] +ru*: + +:_formerr_wrongboard +en : Wrong board: [_1] +ru*: + +:_formerr_tagexists +en : Tag [url,_1,_2] already exists! +ru*: + +:_formerr_tpl_mail +en : Invalid email address +ru*: + +:_formerr_tpl_url +en : [_1]: Invalid URL +ru*: + +:_formerr_tpl_asciiprint +en : [_1] may only contain ASCII characters +ru*: + +:_formerr_tpl_int +en : [_1]: Not a valid number +ru*: + +:_formerr_tpl_pname +en : [_1] can only contain lowercase alphanumberic characters and a hyphen, and must start with a character +ru*: + +:_form_tab_all +en : All items +ru*: + +:_form_editsum +en : Edit summary +ru*: + +:_form_submit +en : Submit +ru*: + + ############################################################################# 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 $rule->{name} already exists!| - : qq|A tag with the same name has been deleted in the past,| - .qq| please use the discussion board 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/&/&/; $txt =~ s//>/; - 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; } -- cgit v1.2.3