i18n by python don't work in web -


  1. both "cn" , "en" works in terminal
  2. "en" works in web, "cn" don't work;

how make "cn" work in web ?

btw: msgfmt, fedora18, httpd;

test.py:

#!/usr/bin/env python # -*- coding: utf-8 -*- import gettext gettext.install('lang', './locale', unicode=true) gettext.translation('lang', './locale', languages=['cn']).install(true)  print "content-type: text/plain\n"  print _("hello world!") print "中文" 

terminal output "cn":

[root@localhost cgi-bin]# ./test.py  content-type: text/plain  中文 

terminal output "en":

[root@localhost cgi-bin]# ./test.py  content-type: text/plain  works. 中文 

webpage "en":

it works. 中文 

webpage "cn": show nothing

"curl locahost/cgi-bin/test.py" "cn": return nothing

locale/cn/lc_messages/lang.po:

# descriptive title. # copyright (c) year organization # first author <email@address>, year. # msgid "" msgstr "" "project-id-version: package version\n" "pot-creation-date: 2013-08-12 05:20+edt\n" "po-revision-date: year-mo-da ho:mi+zone\n" "last-translator: full name <email@address>\n" "language-team: language <ll@li.org>\n" "mime-version: 1.0\n" "content-type: text/plain; charset=utf-8\n" "content-transfer-encoding: utf-8\n" "generated-by: pygettext.py 1.5\n"  msgid "hello world!" msgstr "你好!" 

locale/en/lc_messages/lang.po:

# descriptive title. # copyright (c) year organization # first author <email@address>, year. # msgid "" msgstr "" "project-id-version: package version\n" "pot-creation-date: 2013-08-12 05:20+edt\n" "po-revision-date: year-mo-da ho:mi+zone\n" "last-translator: full name <email@address>\n" "language-team: language <ll@li.org>\n" "mime-version: 1.0\n" "content-type: text/plain; charset=utf-8\n" "content-transfer-encoding: utf-8\n" "generated-by: pygettext.py 1.5\n"  msgid "hello world!" msgstr "it works." 

path:

/var/www/cgi-bin/ |-- locale |   |-- cn |   |   `-- lc_messages |   |       |-- lang.mo |   |       `-- lang.po |   `-- en |       `-- lc_messages |           |-- lang.mo |           `-- lang.po `-- test.py 


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -