本文整理匯總了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)