一个django应用程序,它提供了一个帮助器,用于生成带有i18n支持的静态文件的javascript下划线模板。

django-static-underscore-i18n的Python项目详细描述


django-static-underline-i18n
=======

图片::https://travis-ci.org/cubicova17/django-static-underline-i18n.png?branch=master
:alt:build status
:target:https://travis ci.org/zyegfryed/django-static-underline-i18n

>一个django应用程序,它为将下划线模板编译为支持i18的静态文件提供帮助。

overview
--

``
`github.com/zyefryed/django-static i18n``解决将下划线模板编译为单个静态js文件的问题。
原始代码生成静态js文件以进行翻译。

模块(没有js``gettext``)。如果使用下划线模板,则可以使用如下项目目录::

<;项目目录>;/

语言环境/
+-en/
+-fr/
模板/
+-下划线/
+-popup.html
+-modals/
+-include/
+-main.html


和您的“popup.html”看起来像::

<;div>;
{%trans“您好”%}<;%username%>;
<;/div>;


并且您希望在诸如backbone::

popup view=backbone.view.extend({
模板:\.template(弹出变量名),
});

若要执行此操作,您需要编译.html模板,使其在js中具有“弹出变量名”。此外,如果您有多个模板,您可以将它们捆绑到单个js文件中,并通过cdn或nginx ommiting django来提供。

使用``django-static-underline-i18n``您可以通过以下方法来完成此操作。声明HTML文件和JS变量名之间的字典映射::


静态下划线模板={'popup_variable_name':'下划线/popup.html',…,}

,然后运行“python manage.py compilejsunderscorei18n”,这将把html模板捆绑到一个js文件中,用于每个支持i18``{%trans%}`标记的区域设置。

_ javascript目录视图:https://docs.djangoproject.com/en/1.6/topics/i18n/translation/module django.views.i18n
…_增加开销:https://docs.djangoproject.com/en/1.6/topics/i18n/translation/注意性能
…_ github.com/zyefryed/django-statici18n:https://github.com/zyefryed/django-statici18n


使用您最喜欢的python打包工具从“pypi”安装“django-staticunderline-i18n`
,例如::


pip install django-static-underline-i18n

2。在“已安装的应用程序”设置中添加“`'staticunderline18n```设置::

installed\u apps=[
\…
'staticunderline18n',
]


3。编辑下划线.html模板或“translated”和“compiled”消息后,请使用
``compilejsunderscorei18n``管理命令:


4。检查“django.core.context_processors.i18n”上下文处理器是否已添加到
“template_context_processors”设置中-应该已由
django设置。这需要在编译阶段解析request.language_代码变量::

template_context_processors=(

'django.core.context_processors.i18n',



,您应该有“filesystemfinder”和“appdirectoriesfinder”可用::

staticfiles_finders=(
'django.contrib.staticfiles.finders.filesystemfinder',
'django.contrib.staticfiles.finders.appdirectoriesfinder',



5.编辑模板并插入编译过的.js文件。好的做法是在没有django服务器的情况下提供静态文件(您可以X表示:

…代码块:html+django注意:

默认情况下,生成的目录存储在“static_root/jsunderline18n``.
您可以通过调整
``django-staticunderline18n``设置来修改输出路径和更多选项。

_ pypi:http://pypi.python.org/pypi/django-static-underline-i18n
。_翻译:https://docs.djangoproject.com/en/1.6/topics/i18n/translation/消息文件
…_编译:https://docs.djangoproject.com/en/1.6/topics/i18n/translation/编译消息文件

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何强制用户在允许访问活动之前处理对话框?我的许可证代码怎么了?   java ArraysList作为JSON   mysql如何在java中创建包含多个可选where子句的搜索语句?   java如何让Apache Camel在“直接”路径的末尾删除文件?   使用socket在两个Androids之间进行java实时数据传输。IO(websocket)和4G   如何在java中实现两个CORBA服务器之间的通信   会话树xml表示为java对象   java Skype4Java编号swtwin323325   java RecyclerView getAdapterPosition()不工作:第一次单击返回正确位置,第二次单击返回1   java在$TOMCAT/conf/context上为JNDI设置资源。xml   java为什么第二个矩形冲突在第一个矩形冲突时不起作用?   JScrollPane上的java JTextArea未出现在JPanel上   java如何将实现的PriorityQueue打印为字符串?   jpa使用Jersey更新用户角色RESTJava(JAXRS)