一个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/编译消息文件
=======
图片::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/编译消息文件