fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2011-10-24 11:15 am

[dw-free] English-strip cgi-bin/LJ/CleanHTML.pm

[commit: http://hg.dwscoalition.org/dw-free/rev/5944e2aac132]

http://bugs.dwscoalition.org/show_bug.cgi?id=1361

Move hardcoded text to the translation system. Also edit <b> tags to
<em>.

Patch by [personal profile] ninetydegrees.

Files modified:
  • bin/upgrading/en.dat
  • cgi-bin/LJ/CleanHTML.pm
--------------------------------------------------------------------------------
diff -r 1e343cacbfd2 -r 5944e2aac132 bin/upgrading/en.dat
--- a/bin/upgrading/en.dat	Mon Oct 24 18:46:21 2011 +0800
+++ b/bin/upgrading/en.dat	Mon Oct 24 19:12:04 2011 +0800
@@ -35,6 +35,14 @@
 
 captcha.title=Please fill out the CAPTCHA as an anti-spam measure
 
+cleanhtml.error.markup=( <a [[aopts]]>Error: Irreparable invalid markup in entry. Raw contents behind the cut.</a> )
+
+cleanhtml.error.markup.extra=[<strong>Error:</strong> Irreparable invalid markup ('&lt;[[aopts]]&gt;') in entry. Owner must fix manually. Raw contents below.]
+
+cleanhtml.error.template=[Error: unknown template [[aopts]]]
+
+cleanhtml.error.template.video=[Error: unknown template 'video']
+
 cleanhtml.suspend_msg=This is a suspended entry.
 
 cleanhtml.suspend_msg_with_supportid=This is a suspended entry. <a [[aopts]]>An unsuspension request</a> has been opened and this entry will be reviewed soon.
diff -r 1e343cacbfd2 -r 5944e2aac132 cgi-bin/LJ/CleanHTML.pm
--- a/cgi-bin/LJ/CleanHTML.pm	Mon Oct 24 18:46:21 2011 +0800
+++ b/cgi-bin/LJ/CleanHTML.pm	Mon Oct 24 19:12:04 2011 +0800
@@ -222,11 +222,11 @@
         $edata =~ s/\r?\n/<br \/>/g if $addbreaks;
 
         if ( $cuturl ) {
-            $extra_text = "<b>&nbsp;(<a href=\"" . LJ::ehtml( $cuturl ) . "\">Error: Irreparable invalid markup in entry. Raw contents behind the cut.</a>&nbsp;)</b>";
+            my $cutlink = LJ::ehtml( $cuturl );
+            $extra_text = "<strong>" . LJ::Lang::ml( 'cleanhtml.error.markup', { aopts => $cutlink } ) . "</strong>";
         }
         else {
-            $extra_text = "[<b>Error:</b> Irreparable invalid markup ('&lt;$tag&gt;') in entry.  ".
-                      "Owner must fix manually.  Raw contents below.]<br /><br />" .
+            $extra_text = LJ::Lang::ml( 'cleanhtml.error.markup.extra', { aopts => $tag } ) . "<br /><br />" .
                       '<div style="width: 95%; overflow: auto">' . $edata . '</div>';
         }
 
@@ -331,7 +331,8 @@
                     my ($token, $override_capture) = @_;
                     my $capture = $override_capture ? [$token] : \@capture;
                     my $expanded = ($name =~ /^\w+$/) ? LJ::Hooks::run_hook("expand_template_$name", $capture) : "";
-                    $newdata .= $expanded || "<b>[Error: unknown template '" . LJ::ehtml($name) . "']</b>";
+                    my $template = LJ::ehtml( $name );
+                    $newdata .= $expanded || "<strong>" . LJ::Lang::ml( 'cleanhtml.error.template', { aopts => $template } ) . "</strong>";
                 };
 
                 if ($attr->{'/'}) {
@@ -384,7 +385,7 @@
             if (($tag eq "div" || $tag eq "span") && lc $attr->{class} eq "ljvideo") {
                 $start_capture->($tag, $token, sub {
                     my $expanded = LJ::Hooks::run_hook("expand_template_video", \@capture);
-                    $newdata .= $expanded || "<b>[Error: unknown template 'video']</b>";
+                    $newdata .= $expanded || "<strong>" . LJ::Lang::ml( 'cleanhtml.error.template.video' ) . "</strong>";
                 });
                 next TOKEN;
             }
--------------------------------------------------------------------------------

Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org