本文整理汇总了Python中django.utils.jslex.prepare_js_for_gettext方法的典型用法代码示例。如果您正苦于以下问题:Python jslex.prepare_js_for_gettext方法的具体用法?Python jslex.prepare_js_for_gettext怎么用?Python jslex.prepare_js_for_gettext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.utils.jslex
的用法示例。
在下文中一共展示了jslex.prepare_js_for_gettext方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: preprocess
# 需要导入模块: from django.utils import jslex [as 别名]
# 或者: from django.utils.jslex import prepare_js_for_gettext [as 别名]
def preprocess(self):
"""
Preprocess (if necessary) a translatable file before passing it to
xgettext GNU gettext utility.
"""
from django.utils.translation import templatize
if not self.is_templatized:
return
with io.open(self.path, 'r', encoding=settings.FILE_CHARSET) as fp:
src_data = fp.read()
if self.domain == 'djangojs':
content = prepare_js_for_gettext(src_data)
elif self.domain == 'django':
content = templatize(src_data, self.path[2:])
with io.open(self.work_path, 'w', encoding='utf-8') as fp:
fp.write(content)
示例2: preprocess
# 需要导入模块: from django.utils import jslex [as 别名]
# 或者: from django.utils.jslex import prepare_js_for_gettext [as 别名]
def preprocess(self):
"""
Preprocess (if necessary) a translatable file before passing it to
xgettext GNU gettext utility.
"""
if not self.is_templatized:
return
encoding = settings.FILE_CHARSET if self.command.settings_available else 'utf-8'
with io.open(self.path, 'r', encoding=encoding) as fp:
src_data = fp.read()
if self.domain == 'djangojs':
content = prepare_js_for_gettext(src_data)
elif self.domain == 'django':
content = templatize(src_data, origin=self.path[2:], charset=encoding)
with io.open(self.work_path, 'w', encoding='utf-8') as fp:
fp.write(content)