Index: wp-includes/script-loader.php
===================================================================
--- wp-includes/script-loader.php (revision 16581)
+++ wp-includes/script-loader.php (working copy)
@@ -374,11 +374,20 @@
$scripts->add( 'admin-widgets', "/wp-admin/js/widgets$suffix.js", array( 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-droppable' ), '20101007' );
$scripts->add_data( 'admin-widgets', 'group', 1 );
+
+ if ( defined( 'WPLANG' ) && preg_match( '/^(bo|dz|ii|ja|km|my|th|zh)/', WPLANG ) ) {
+ $counting_string = __('Character count: %d');
+ $counting_method = 'character';
+ } else {
+ $counting_string = __('Word count: %d');
+ $counting_method = 'word';
+ }
$scripts->add( 'word-count', "/wp-admin/js/word-count$suffix.js", array( 'jquery' ), '20090422' );
$scripts->add_data( 'word-count', 'group', 1 );
$scripts->localize( 'word-count', 'wordCountL10n', array(
- 'count' => __('Word count: %d'),
+ 'count' => $counting_string,
+ 'method' => $counting_method,
'l10n_print_after' => 'try{convertEntities(wordCountL10n);}catch(e){};'
));
Index: wp-admin/js/word-count.dev.js
===================================================================
--- wp-admin/js/word-count.dev.js (revision 16578)
+++ wp-admin/js/word-count.dev.js (working copy)
@@ -24,9 +24,19 @@
setTimeout( function() {
if ( tx ) {
- tx = tx.replace( /<.[^<>]*?>/g, ' ' ).replace( / | /gi, ' ' );
- tx = tx.replace( /[0-9.(),;:!?%#$¿'"_+=\\/-]*/g, '' );
- tx.replace( /\S\s+/g, function(){tc++;} );
+ if (wordCountL10n.method == 'character') {
+ tx = tx.replace(/<.[^<>]*?>/g, '');
+ tx = tx.replace(/&(nbsp|#160|#x00a0);/gi, '');
+ tx = tx.replace(/[ \s]/g, '');
+ tx = tx.replace(/&(#[\d]{2,5}|#x[a-fA-F\d]{1,4}|[a-zA-Z]{2,8}[1-4]{0,2});/g, ' ');
+ tc = tx.length;
+ } else {
+ tx = tx.replace(/<.[^<>]*?>/g, " ").replace(/ | /gi, " ");
+ tx = tx.replace(/[0-9.(),;:!?%#$¿'"_+=\\/-]*/g, "");
+ tx.replace(/\S\s+/g, function () {
+ tc++;
+ });
+ }
}
w.html(tc.toString());
Index: wp-admin/js/word-count.js
===================================================================
--- wp-admin/js/word-count.js (revision 16578)
+++ wp-admin/js/word-count.js (working copy)
@@ -1 +1 @@
-(function(a){wpWordCount={init:function(){var b=this,c=0,d=a("#content");a("#wp-word-count").html(wordCountL10n.count.replace(/%d/,'0'));b.block=0;b.wc(d.val());d.keyup(function(f){if(f.keyCode==c){return true}if(13==f.keyCode||8==c||46==c){b.wc(d.val())}c=f.keyCode;return true})},wc:function(d){var e=this,c=a("#word-count"),b=0;if(e.block){return}e.block=1;setTimeout(function(){if(d){d=d.replace(/<.[^<>]*?>/g," ").replace(/ | /gi," ");d=d.replace(/[0-9.(),;:!?%#$¿'"_+=\\/-]*/g,"");d.replace(/\S\s+/g,function(){b++})}c.html(b.toString());setTimeout(function(){e.block=0},2000)},1)}};a(document).ready(function(){wpWordCount.init()})}(jQuery));
\ No newline at end of file
+(function(a){wpWordCount={init:function(){var b=this,c=0,d=a("#content");a("#wp-word-count").html(wordCountL10n.count.replace(/%d/,'0'));b.block=0;b.wc(d.val());d.keyup(function(f){if(f.keyCode==c){return true}if(13==f.keyCode||8==c||46==c){b.wc(d.val())}c=f.keyCode;return true})},wc:function(d){var e=this,c=a("#word-count"),b=0;if(e.block){return}e.block=1;setTimeout(function(){if (d) {if ( wordCountL10n.method == 'character' ) {d = d.replace( /<.[^<>]*?>/g, '' );d = d.replace( /&(nbsp|#160|#x00a0);/gi, '' );d = d.replace( /[ \s]/g, '' );d = d.replace( /&(#[\d]{2,5}|#x[a-fA-F\d]{1,4}|[a-zA-Z]{2,8}[1-4]{0,2});/g, ' ' );b = d.length;} else {d = d.replace(/<.[^<>]*?>/g, " ").replace(/ | /gi, " ");d = d.replace(/[0-9.(),;:!?%#$¿'"_+=\\/-]*/g, "");d.replace(/\S\s+/g, function () {b++;});}}c.html(b.toString());setTimeout(function(){e.block=0},2000)},1)}};a(document).ready(function(){wpWordCount.init()})}(jQuery));
\ No newline at end of file