[英]Any detailed documentation about the Chameleon Template in Pyramid Web Framework?
[英]How to use internationalization in chameleon with pyramid web framework?
我已經完成以下工作:
pyramid.default_locale_name = en
更改為pyramid.default_locale_name = en
中的de
我的index.pt
看起來像這樣:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" xmlns:tal="http://xml.zope.org namespaces/tal" xmlns:i18n="http://xml.zope.org/namespaces/i18n" i18n:domain="mvc"> <a href="/user/login/form" i18n:translate="">Login Page</a><br /> <a href="/user/register/form" i18n:translate="">Register Page</a><br /> <a href="/ds/landing/view" i18n:translate="">Datasource landing page</a> <br /> <p>${locale_name}</p>
我對setup.py進行了更改
message_extractors = { '.': [ ('**.py', 'lingua_python', None ), ('**.pt', 'lingua_xml', None ), ]}
當我運行python setup.py extract_messages
和python setup.py update_catalog
我的locale/de/LC_MESSAGES/mvc.po
會獲取所有字符串。 翻譯后變成
# German translations for mvc. # Copyright (C) 2012 ORGANIZATION # This file is distributed under the same license as the mvc project. # FIRST AUTHOR <EMAIL@ADDRESS>, 2012. # msgid "" msgstr "" "Project-Id-Version: mvc 0.0\\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\\n" "POT-Creation-Date: 2012-05-02 12:24+0530\\n" "PO-Revision-Date: 2012-05-02 11:38+0530\\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\\n" "Language-Team: de <LL@li.org>\\n" "Plural-Forms: nplurals=2; plural=(n != 1)\\n" "MIME-Version: 1.0\\n" "Content-Type: text/plain; charset=utf-8\\n" "Content-Transfer-Encoding: 8bit\\n" "Generated-By: Babel 0.9.6\\n" #: mvc/templates/index.pt:2 msgid "Login Page" msgstr "sign in page" #: mvc/templates/index.pt:3 #, fuzzy msgid "Register Page" msgstr "register in this Page" #: mvc/templates/index.pt:4 msgid "Datasource landing page" msgstr "Landing Page of datasources"
忽略英語,因為我沒有做任何實際的翻譯。 我想檢查一下是否有效。
我做了python setup.py compie_catalog
和mvc.mo文件創建
但是,當我加載頁面時,我得到的是同一頁面,而翻譯沒有被拾取。 從視圖中可以看到,語言環境似乎已正確設置
@view_config(route_name='home',renderer='templates/index.pt') def index_view(request): from pyramid.i18n import negotiate_locale_name return {'locale_name' : negotiate_locale_name(request)}
我什至將config.add_translation_dirs('mvc:locale')
到我的init .py中
我究竟做錯了什么? 還是我什么都沒做?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.