修改Translate Widget以适应中文Blog

Translate Widget是一个加拿大小伙子为Wordpress Blog编写的翻译插件,使用了Google的翻译服务,但由于作者是基于英文站点编写的,因此插件默认的Blog语言为英文,并且没有提供直观的选项更改,对于中文站点并不适用,如果我们想使用这个服务,需要手动修改这个插件,所幸并不复杂:wink:

  • 用一个文本编辑器打开translate.php文件
  • 将第41行的‘Chinese’ => ‘zh-CN’改为‘English’ => ‘en’
  • 将第5354行的
    $langname=’English’;
    $langcode=’en’;

    改为
    $langname=’Chinese’;
    $langcode=’zh-CN’;
  • 将第5168行中的en替换为zh-CN,如http://www.google.com/translate?hl=en&ie=UTF8&langpair=en%7C$langcode&u=$url改为
    http://www.google.com/translate?hl=zh-CN&ie=UTF8&langpair=zh-CN%7C$langcode&u=$url

这样就可以把中文Blog翻译成其他语言了,可以参考本站点左侧的Translate栏目。

下载修改好的Translate Widget插件

Tags: , , ,

4 Responses to “修改Translate Widget以适应中文Blog”

  1. Trevor Says:

    Great explanation!
    It’s neat to see my plugin modified to work with other languages :) I might add that as an option in future versions.

  2. Jason Chao Says:

    Hi, Trevor, I am very pleased to see your comment:wink:, and looking forward to the next version, I think it will be more wonderful!

  3. Trevor Says:

    Hi,
    I have now added this functionality to my plugin by default. You can find it here: http://trevorcreech.com/blog/2007/02/17/translate-widget-20/

  4. Jason Chao Says:

    [quote comment="3349"]Hi,
    I have now added this functionality to my plugin by default. You can find it here: http://trevorcreech.com/blog/2007/02/17/translate-widget-20//quote
    Good job!

Leave a Reply