6.2. 根据浏览器喜好自动选择缺省语种

from pylons.i18n import set_lang, add_fallback

class BaseController(WSGIController):
    def __before__(self, action):

        if 'lang' in session:
            set_lang(session['lang'])
        for lang in request.languages:
            if lang in ['zh', 'en']:
                add_fallback(lang)