d开发者_运维问答jango.po\" but has any way to do this on gae?" />
开发者

how to make site show different language(chinese and english) on google-app-engine

if you using django ,you can use the "LC_MESSAGES -->d开发者_运维问答jango.po"

but has any way to do this on gae ?

and how to ..

thanks

and if i only want to use django's this features, how can i import it?


Try this snippet:

urls.py:

from django.conf import settings
try:
    settings.configure()
except:
    pass
settings.LANGUAGE_CODE = 'zh-tw'
settings.USE_I18N = True
appdir = os.path.abspath( os.path.dirname( __file__ ) )
settings.LOCALE_PATHS = ( 
    os.path.join( appdir, 'locale' ),
 )
from django.utils.translation import *

for each request:

class Page(webapp.RequestHandler):
    def getLanguage(self):
        try:
            language = self.request.cookies['django_language']
            self.locate = language
            logging.info( "Get Language as %s" % self.locate )
        except:
            from django.conf import settings
            self.locate = settings.LANGUAGE_CODE
            logging.info( "Set Language as %s" % self.locate )            
        translation.activate( self.locate )
    def get(self):
        self.getLanguage()
        #...


I had the same question, and it was answered here.

That way I managed to internationalize my GAE app by using standard gettext tools. If your app is open source, you can even enjoy translations on Launchpad!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜