本文整理汇总了Python中django.views.i18n.JavaScriptCatalog.get_catalog方法的典型用法代码示例。如果您正苦于以下问题:Python JavaScriptCatalog.get_catalog方法的具体用法?Python JavaScriptCatalog.get_catalog怎么用?Python JavaScriptCatalog.get_catalog使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.views.i18n.JavaScriptCatalog
的用法示例。
在下文中一共展示了JavaScriptCatalog.get_catalog方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: generate_widget_js
# 需要导入模块: from django.views.i18n import JavaScriptCatalog [as 别名]
# 或者: from django.views.i18n.JavaScriptCatalog import get_catalog [as 别名]
def generate_widget_js(lang):
code = []
with language(lang):
# Provide isolation
code.append('(function (siteglobals) {\n')
code.append('var module = {}, exports = {};\n')
code.append('var lang = "%s";\n' % lang)
c = JavaScriptCatalog()
c.translation = DjangoTranslation(lang, domain='djangojs')
catalog, plural = c.get_catalog(), c.get_plural()
str_wl = (
'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su',
'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August',
'September', 'October', 'November', 'December'
)
catalog = dict((k, v) for k, v in catalog.items() if k.startswith('widget\u0004') or k in str_wl)
template = Engine().from_string(js_catalog_template)
context = Context({
'catalog_str': indent(json.dumps(
catalog, sort_keys=True, indent=2)) if catalog else None,
'formats_str': indent(json.dumps(
get_formats(), sort_keys=True, indent=2)),
'plural': plural,
})
code.append(template.render(context))
files = [
'vuejs/vue.js' if settings.DEBUG else 'vuejs/vue.min.js',
'vuejs/vue-resize.min.js',
'pretixpresale/js/widget/docready.js',
'pretixpresale/js/widget/floatformat.js',
'pretixpresale/js/widget/widget.js',
]
for fname in files:
f = finders.find(fname)
with open(f, 'r') as fp:
code.append(fp.read())
if settings.DEBUG:
code.append('})(this);\n')
else:
# Do not expose debugging variables
code.append('})({});\n')
return ''.join(code)
示例2: js_catalog
# 需要导入模块: from django.views.i18n import JavaScriptCatalog [as 别名]
# 或者: from django.views.i18n.JavaScriptCatalog import get_catalog [as 别名]
def js_catalog(request, lang):
c = JavaScriptCatalog()
c.translation = DjangoTranslation(lang, domain='djangojs')
return render_javascript_catalog(c.get_catalog(), c.get_plural())