Personal tools
You are here: Home 博客群 潘俊勇的Blog 2006 2006-1 在Plone脚本中进行汉字到拼音的转换
Log in


Forgot your password?
Recent Comments
 dsfds (Anonymous User) 2008-12-30
 MrinMjOTWVPfgqm (Anonymous User) 2008-12-24
 NYdaTWdZMtXHzKpleru (Anonymous User) 2008-12-14
 牵强附会 (Anonymous User) 2008-11-11
 
Document Actions

在Plone脚本中进行汉字到拼音的转换 在Plone脚本中进行汉字到拼音的转换

Submitted by panjy. on 2006-01-12 05:51. Plone
Plone2.1中,如果安装了 ZopeChinaPak_ , 会发现新内容的英文代号会自动从中

Plone2.1中,如果安装了 ZopeChinaPak , 会发现新内容的英文代号会自动从中 文标题转换为拼音。

在论坛里看到有人希望将用户名按照拼音进行排序,这就需要知道这个汉字->拼音 的接口了。

实际上很简单,调用Plone的plone_utils工具的normalizeString方法就可以了,如:

context.plone_utils.normalizeString('张三')

这应该直接返回:

zhangsan

恩, 帮助很大呢

Posted by eishn at 2006-01-13 07:46

记得以前安装了潘站写的 ZopeChinaPak, 发现可以自动转换中文到英文 ID, 还特意看了源码。感觉要调用这个功能很麻烦呢。现在看到潘站把接口放出来, 就不用看源码去找了, 呵呵。

为什么我调用给出的函数返回的不是拼音啊?

Posted by Anonymous User at 2006-01-17 07:51

我在plone2.1中安装了ZopeChinaPak0.5,新建的plone站点选择了defautl chinese site。建立了一个python script,里面的全部代码如下:

print context.plone_utils.normalizeString(张三) return printed

test页面中返回的是 5f204e09

这是为什么啊?5555

要使用最新版本0.8.1

Posted by 潘俊勇 at 2006-01-17 08:16

在这里:http://www.zope.org/Members/panjunyong/ZopeChinaPak


Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: