當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。