Regarding the word count problem
Hi there.
The current JavaScript code for counting words in editor ignores Chinese characters, so I am working on a patch which I intend to ship with future cn.wordpress.org packages.
It seems that the easiest fix is to enqueue a modified wp-admin/js/word-count.js. Is it okay to put a modified version under the corresponding SVN dist/ directory, and get the original word-count.js replaced, OR I have to put it under wp-content/languages/ and play around with the hook to make it be queued to load?
Thank you.
Zé 11:10 pm on October 16, 2011 Permalink |
Conceptually, I’d argue that the first option (replacing the original word-count.js) is changing core code, and hence recommend against it. That said, it also depends on what you mean by “play around with the hook to make it be queued to load”. Completely personal and subjective opinion, of course, would love to hear more from the others.
jiehanzheng 11:43 pm on October 16, 2011 Permalink |
Okay then the first option is out. The real issue is that the built-in word counting function is not working for Chinese characters. By “play around with the hook to make it be queued to load” I mean I intend to include a
zh_CN-word-count.jsor something else and add a few lines of code inzh_CN.phpto make it be loaded and deregister the originalword-count.jsso that the original core code remains intact and we can make the word counting work when WPLANG is defined as zh_CN inwp-config.php.Zé 12:00 am on October 17, 2011 Permalink |
This sounds very good, on the other hand
Naoko 1:25 am on October 17, 2011 Permalink |
Japanese package includes a fix for this as a plugin:
http://wordpress.org/extend/plugins/wp-multibyte-patch/
If you’re interested, I’d be happy to help the author translate the whole thing but here’s Google translated version of the description page:
http://translate.google.com/translate?hl=en&sl=auto&tl=en&u=http%3A%2F%2Feastcoder.com%2Fcode%2Fwp-multibyte-patch%2F
Nikolay Bachiyski 3:32 pm on October 17, 2011 Permalink |
@jiehanzheng, I would recommend you do what the Japanese guys did. It’s working great.
jiehanzheng 8:13 pm on October 17, 2011 Permalink |
Cool. Thank you for your advice. So for the plugin solution, am i supposed to include a copy of the plugin under SVN
dist/wp-content/plugins/? Who should be the plugin author, and may I have a WordPress.org account with the namewordpresschina?I will look into it, see how it works during the upcoming school long weekend and hopefully include the fix before our next release. I will post any updates here.
jiehanzheng 8:14 pm on October 17, 2011 Permalink |
Thank you so much, Naoko. It’s a pretty nice idea because of the similarities of Japanese characters and Chinese characters. I will look into it.
The Google Translate version is… to some extend, readable. So thank you for your offer and I will do the research.