2011-01-12 2 views
1

이 코드 :이 코드 mako 읽을 수 캔트,는 장고에 청상 아리를 사용하는 경우 국제화에 대처하는 방법

{% load i18n %} 
{% trans 'hello test' %} 

하지만,

때문에, mako를 사용하여 국제화하는 방법

감사합니다

+1

http://stackoverflow.com/questions/3790854/mako-templates-using-django-template-tags은 비슷하지만, 내 생각은 그 절반 밖에 :

하지만 바벨을 사용하여 생각이 더 예쁜입니다 트랜스에 대한 이야기는 매번 템플릿 블록을 실행해야합니다. –

답변

1

나는 documentation을 확인했으며 Mako는 i18n에 Babel을 사용한다고 설명했습니다. 그래서 당신은 그것을 사용하거나 @Yuji가 제안하는 것처럼 Django의 i18n을 임의의 Python 코드를 호출하여 사용할 수 있습니다.

# /myproj/babel.cfg 

# this loads all Django templates, 
# e.g. /myproj/templates/myapp/hello_world.html 
[mako: **/templates/**.*] 

# /myproj/templates/myapp/hello_world.html 
<html> 
    <body> 
     ${_('Hello world!')} 
    </body> 
</html> 
관련 문제