当前位置: 首页>>代码示例>>Python>>正文


Python jslex.prepare_js_for_gettext方法代码示例

本文整理汇总了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) 
开发者ID:ComputerSocietyUNB,项目名称:CodingDojo,代码行数:22,代码来源:makemessages.py

示例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) 
开发者ID:prakharchoudhary,项目名称:Scrum,代码行数:21,代码来源:makemessages.py


注:本文中的django.utils.jslex.prepare_js_for_gettext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。