ZhCategories

简单定制已有插件,显示中文分类信息

-- Zoom.Quiet [2004-09-08 22:29:23]

pycategories.py

中文化分类显示

技术路线

快速实现

   1 zhlabel={
   2         "":"是也乎"
   3         ,"Quiet":"静空间"
   4         ,"zworld":"众香界"
   5         ,"Zoom":"智慧海"
   6         ,"FLOSS":"FLOSS!自由精神"
   7         ,"Python":"灵蟒!"
   8         ,"Woodpacker":"啄木鸟社区"
   9         ,"CZUG":"中国Zope用户组"
  10         ,"wego":"wego!项目"
  11 }
  12 def chkoutlabel(key):
  13         exp=""
  14         try:
  15                 return zhlabel[key]
  16                 #exp=zhlabel[key]
  17         except:
  18                 return key
  19                 #exp="是也乎"
  20         #return(exp)

   1 # -*- coding: utf-8 -*-
   2 """
   3 pycategories_try.py 辅助脚本,pycategories_zh.py的调用测试
   4 """
   5 if __name__ == '__main__':      # this way the module can be
   6         from pycategories_zh import chkoutlabel as mylabel      
   7         print "wego"
   8         print mylabel("wego")   

   1 #pycategories.py 中:
   2 from pycategories_zh import chkoutlabel as mylabel
   3 ...
   4 def genitem(self, item):
   5 ...
   6     #return (tab + "<a href=\"%s/%s%s\">%s/</a>%s" % (self._baseurl, item, self._flavour, itemlist[-1], num))
   7     return (tab + "<a href=\"%s/%s%s\">%s/</a>%s" % (self._baseurl, item, self._flavour, mylabel(itemlist[-1]), num))

注意!

ZhCategories (last edited 2009-12-25 07:18:52 by localhost)