<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[19795] trunk/wp-includes/formatting.php: Allow the single quotes, apostrophes, and primes in wptexturize() to be translated.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg > ul, #logmsg > ol { margin-left: 0; margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/19795">19795</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2012-01-31 14:06:32 +0000 (Tue, 31 Jan 2012)</dd>
</dl>
<h3>Log Message</h3>
<pre>Allow the single quotes, apostrophes, and primes in wptexturize() to be translated. Allows replacements to be disabled by translating them back to " and '. fixes <a href="http://core.trac.wordpress.org/ticket/19602">#19602</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpincludesformattingphp">trunk/wp-includes/formatting.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpincludesformattingphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/formatting.php (19794 => 19795)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/formatting.php        2012-01-30 20:51:00 UTC (rev 19794)
+++ trunk/wp-includes/formatting.php        2012-01-31 14:06:32 UTC (rev 19795)
</span><span class="lines">@@ -28,18 +28,34 @@
</span><span class="cx"> */
</span><span class="cx"> function wptexturize($text) {
</span><span class="cx">         global $wp_cockneyreplace;
</span><del>-        static $opening_quote, $closing_quote, $en_dash, $em_dash, $default_no_texturize_tags, $default_no_texturize_shortcodes, $static_characters, $static_replacements, $dynamic_characters, $dynamic_replacements;
</del><ins>+        static $opening_quote, $closing_quote, $opening_single_quote, $closing_single_quote, $en_dash, $em_dash,
+                $apos, $prime, $double_prime, $default_no_texturize_tags, $default_no_texturize_shortcodes,
+                $static_characters, $static_replacements, $dynamic_characters, $dynamic_replacements;
</ins><span class="cx">
</span><span class="cx">         // No need to set up these static variables more than once
</span><span class="cx">         if ( empty( $opening_quote ) ) {
</span><del>-                /* translators: opening curly quote */
-                $opening_quote = _x('&#8220;', 'opening curly quote');
-                /* translators: closing curly quote */
-                $closing_quote = _x('&#8221;', 'closing curly quote');
</del><ins>+                /* translators: opening curly double quote */
+                $opening_quote = _x( '&#8220;', 'opening curly double quote' );
+                /* translators: closing curly double quote */
+                $closing_quote = _x( '&#8221;', 'closing curly double quote' );
+
+                /* translators: apostrophe, for example in 'cause or can't */
+                $apos = _x( '&#8217;', 'apostrophe' );
+
+                /* translators: prime, for example in 9' (nine feet) */
+                $prime = _x( '&#8242;', 'prime' );
+                /* translators: double prime, for example in 9" (nine inches) */
+                $double_prime = _x( '&#8243;', 'double prime' );
+
+                /* translators: opening curly single quote */
+                $opening_single_quote = _x( '&#8216;', 'opening curly single quote' );
+                /* translators: closing curly single quote */
+                $closing_single_quote = _x( '&#8217;', 'closing curly single quote' );
+
</ins><span class="cx">                 /* translators: en dash */
</span><del>-                $en_dash = _x('&#8211;', 'en dash');
</del><ins>+                $en_dash = _x( '&#8211;', 'en dash' );
</ins><span class="cx">                 /* translators: em dash */
</span><del>-                $em_dash = _x('&#8212;', 'em dash');
</del><ins>+                $em_dash = _x( '&#8212;', 'em dash' );
</ins><span class="cx">
</span><span class="cx">                 $default_no_texturize_tags = array('pre', 'code', 'kbd', 'style', 'script', 'tt');
</span><span class="cx">                 $default_no_texturize_shortcodes = array('code');
</span><span class="lines">@@ -48,16 +64,40 @@
</span><span class="cx">                 if ( isset($wp_cockneyreplace) ) {
</span><span class="cx">                         $cockney = array_keys($wp_cockneyreplace);
</span><span class="cx">                         $cockneyreplace = array_values($wp_cockneyreplace);
</span><ins>+                } elseif ( "'" != $apos ) { // Only bother if we're doing a replacement.
+                        $cockney = array( "'tain't", "'twere", "'twas", "'tis", "'twill", "'til", "'bout", "'nuff", "'round", "'cause" );
+                        $cockneyreplace = array( $apos . "tain" . $apos . "t", $apos . "twere", $apos . "twas", $apos . "tis", $apos . "twill", $apos . "til", $apos . "bout", $apos . "nuff", $apos . "round", $apos . "cause" );
</ins><span class="cx">                 } else {
</span><del>-                        $cockney = array("'tain't","'twere","'twas","'tis","'twill","'til","'bout","'nuff","'round","'cause");
-                        $cockneyreplace = array("&#8217;tain&#8217;t","&#8217;twere","&#8217;twas","&#8217;tis","&#8217;twill","&#8217;til","&#8217;bout","&#8217;nuff","&#8217;round","&#8217;cause");
</del><ins>+                        $cockney = $cockneyreplace = array();
</ins><span class="cx">                 }
</span><span class="cx">
</span><del>-                $static_characters = array_merge( array('---', ' -- ', '--', ' - ', 'xn&#8211;', '...', '``', '\'\'', ' (tm)'), $cockney );
-                $static_replacements = array_merge( array($em_dash, ' ' . $em_dash . ' ', $en_dash, ' ' . $en_dash . ' ', 'xn--', '&#8230;', $opening_quote, $closing_quote, ' &#8482;'), $cockneyreplace );
</del><ins>+                $static_characters = array_merge( array( '---', ' -- ', '--', ' - ', 'xn&#8211;', '...', '``', '\'\'', ' (tm)' ), $cockney );
+                $static_replacements = array_merge( array( $em_dash, ' ' . $em_dash . ' ', $en_dash, ' ' . $en_dash . ' ', 'xn--', '&#8230;', $opening_quote, $closing_quote, ' &#8482;' ), $cockneyreplace );
</ins><span class="cx">
</span><del>-                $dynamic_characters = array('/\'(\d\d(?:&#8217;|\')?s)/', '/\'(\d)/', '/(\s|\A|[([{<]|")\'/', '/(\d)"/', '/(\d)\'/', '/(\S)\'([^\'\s])/', '/(\s|\A|[([{<])"(?!\s)/', '/"(\s|\S|\Z)/', '/\'([\s.]|\Z)/', '/\b(\d+)x(\d+)\b/');
-                $dynamic_replacements = array('&#8217;$1','&#8217;$1', '$1&#8216;', '$1&#8243;', '$1&#8242;', '$1&#8217;$2', '$1' . $opening_quote . '$2', $closing_quote . '$1', '&#8217;$1', '$1&#215;$2');
</del><ins>+                $dynamic = array();
+                if ( "'" != $apos ) {
+                        $dynamic[ '/\'(\d\d(?:&#8217;|\')?s)/' ] = $apos . '$1'; // '99's
+                        $dynamic[ '/\'(\d)/' ] = $apos . '$1'; // '99
+                }
+                if ( "'" != $opening_single_quote )
+                        $dynamic[ '/(\s|\A|[([{<]|")\'/' ] = '$1' . $opening_single_quote; // opening single quote, even after (, {, <, [
+                if ( '"' != $double_prime )
+                        $dynamic[ '/(\d)"/' ] = '$1' . $double_prime; // 9" (double prime)
+                if ( "'" != $prime )
+                        $dynamic[ '/(\d)\'/' ] = '$1' . $prime; // 9' (prime)
+                if ( "'" != $apos )
+                        $dynamic[ '/(\S)\'([^\'\s])/' ] = '$1' . $apos . '$2'; // apostrophe in a word
+                if ( '"' != $opening_quote )
+                        $dynamic[ '/(\s|\A|[([{<])"(?!\s)/' ] = '$1' . $opening_quote . '$2'; // opening double quote, even after (, {, <, [
+                if ( '"' != $closing_quote )
+                        $dynamic[ '/"(\s|\S|\Z)/' ] = $closing_quote . '$1'; // closing double quote
+                if ( "'" != $closing_single_quote )
+                        $dynamic[ '/\'([\s.]|\Z)/' ] = $closing_single_quote . '$2'; // closing single quote
+
+                $dynamic[ '/\b(\d+)x(\d+)\b/' ] = '$1&#215;$2'; // 9x9 (times)
+
+                $dynamic_characters = array_keys( $dynamic );
+                $dynamic_replacements = array_values( $dynamic );
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         // Transform into regexp sub-expression used in _wptexturize_pushpop_element
</span></span></pre>
</div>
</div>
</body>
</html>