Андрей (andy) wrote in changelog,
Андрей
andy
changelog

[livejournal] r19137: LJSUP-8878 (Need create variable for tex...

Committer: ailyin
LJSUP-8878 (Need create variable for text "Your email address cannot be blank.")
U   trunk/bin/upgrading/en.dat
U   trunk/cgi-bin/emailcheck.pl
Modified: trunk/bin/upgrading/en.dat
===================================================================
--- trunk/bin/upgrading/en.dat	2011-05-26 06:57:48 UTC (rev 19136)
+++ trunk/bin/upgrading/en.dat	2011-05-26 07:44:57 UTC (rev 19137)
@@ -1185,6 +1185,20 @@
 [[siteroot]]/
 .
 
+emailcheck.error.bad_aol_spelling=You gave [[email]] as your email address.  Are you sure you didn't mean aol.com?
+
+emailcheck.error.bad_domain=Your email address domain is invalid.
+
+emailcheck.error.bad_form=You did not give a valid email address.  An email address looks like username@some.domain
+
+emailcheck.error.bad_hotmail_spelling=You gave [[email]] as your email address.  Are you sure you didn't mean hotmail.com?
+
+emailcheck.error.bad_username=You have invalid characters in your email address username.
+
+emailcheck.error.empty=Your email address cannot be blank.
+
+emailcheck.error.web_address=You gave [[email]] as your email address, but it looks more like a web address to me.
+
 entryform.adultcontent|staleness=1
 entryform.adultcontent=Adult Content:
 

Modified: trunk/cgi-bin/emailcheck.pl
===================================================================
--- trunk/cgi-bin/emailcheck.pl	2011-05-26 06:57:48 UTC (rev 19136)
+++ trunk/cgi-bin/emailcheck.pl	2011-05-26 07:44:57 UTC (rev 19137)
@@ -24,20 +24,16 @@
     $email = lc $email;
 
     my $reject = sub {
-        my $errcode = shift;
-        my $errmsg = shift;
-        # TODO: add $opts to end of check_email and make option 
-        #       to either return error codes, or let caller supply
-        #       a subref to resolve error codes into native language
-        #       error messages (probably via BML::ML hash, or something)
-        push @$errors, $errmsg; 
+        my ( $errcode, $opts ) = @_;
+
+        # TODO: figure out a way to return error code to the caller
+        push @$errors, LJ::Lang::ml( "emailcheck.error.$errcode", $opts );
         return;
     };
 
     # Empty email addresses are not good.
     unless ($email) {
-        return $reject->("empty",
-                         "Your email address cannot be blank.");
+        return $reject->('empty');
     }
 
     # Check that the address is of the form username@some.domain.
@@ -46,44 +42,38 @@
         $username = $1;
         $domain = $2;
     } else {
-        return $reject->("bad_form",
-                         "You did not give a valid email address.  An email address looks like username\@some.domain");
+        return $reject->('bad_form');
     }
 
     # Check the username for invalid characters.
     unless ($username =~ /^[^\s\",;\(\)\[\]\{\}\<\>]+$/) {
-        return $reject->("bad_username",
-                         "You have invalid characters in your email address username.");
+        return $reject->('bad_username');
     }
 
     # Check the domain name.
     unless ($domain =~ /^[\w-]+(\.[\w-]+)*\.(ac|ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|info|int|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)$/)
     {
-        return $reject->("bad_domain",
-                         "Your email address domain is invalid.");
+        return $reject->('bad_domain');
     }
 
     # Catch misspellings of hotmail.com
     if ($domain =~ /^(otmail|hotmial|hotmil|hotamail|hotmaul|hoatmail|hatmail|htomail)\.(cm|co|com|cmo|om)$/ or
         $domain =~ /^hotmail\.(cm|co|om|cmo)$/)
     {
-        return $reject->("bad_hotmail_spelling",
-                         "You gave $email as your email address.  Are you sure you didn't mean hotmail.com?");
+        return $reject->( 'bad_hotmail_spelling', { 'email' => $email } );
     }
 
     # Catch misspellings of aol.com
     elsif ($domain =~ /^(ol|aoll)\.(cm|co|com|cmo|om)$/ or
            $domain =~ /^aol\.(cm|co|om|cmo)$/)
     {
-        return $reject->("bad_aol_spelling",
-                         "You gave $email as your email address.  Are you sure you didn't mean aol.com?");
+        return $reject->( 'bad_aol_spelling', { 'email' => $email } );
     }
 
     # Catch web addresses (two or more w's followed by a dot)
     elsif ($username =~ /^www*\./)
     {
-        return $reject->("web_address",
-                         "You gave $email as your email address, but it looks more like a web address to me.");
+        return $reject->( 'web_address', { 'email' => $email } );
     }
 }
 

Tags: andy, dat, livejournal, pl
Subscribe

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments