def render(self, context, instance, placeholder): if settings.CMS_DBGETTEXT: from dbgettext.parser import parsed_gettext instance.topic = parsed_gettext(instance, 'topic') instance.body = parsed_gettext(instance, 'body') context.update({ 'body':plugin_tags_to_user_html(instance.body, context, placeholder), 'topic':instance.topic, 'css' : instance.get_css_display(), 'placeholder':placeholder, 'object':instance, }) return context
def gettext(self): """ Export translatable strings from models into static files """ def write(file, string): string = string.replace('"', '\\"') # prevent """" string = string.encode("utf8") file.write('# -*- coding: utf-8 -*-\ngettext("""%s""")\n' % string) root = os.path.join(self.path, self.root) # remove any old files if os.path.exists(root): rmtree(root) # for each registered model: for model, options in registry._registry.items(): for obj in build_queryset(model): path = os.path.join(root, build_path(obj)) if not os.path.exists(path): os.makedirs(path) for attr_name in options.attributes: attr = get_field_or_callable_content(obj, attr_name) if attr: f = open(os.path.join(path, "%s.py" % attr_name), "w") write(f, attr) f.close() for attr_name in options.parsed_attributes: f = open(os.path.join(path, "%s.py" % attr_name), "w") for s in parsed_gettext(obj, attr_name, export=True): write(f, s) f.close()
def gettext(self): """ Export translatable strings from models into static files """ def write(file, string): string = string.replace('"','\\"') # prevent """" string = string.encode('utf8') file.write('# -*- coding: utf-8 -*-\ngettext("""%s""")\n' % string) root = os.path.join(self.path, self.root) # remove any old files if os.path.exists(root): rmtree(root) # for each registered model: for model, options in registry._registry.items(): for obj in build_queryset(model): path = os.path.join(root, build_path(obj)) if not os.path.exists(path): os.makedirs(path) for attr_name in options.attributes: attr = get_field_or_callable_content(obj, attr_name) if attr: f = open(os.path.join(path, '%s.py' % attr_name), 'w') write(f, attr) f.close() for attr_name in options.parsed_attributes: f = open(os.path.join(path, '%s.py' % attr_name), 'w') for s in parsed_gettext(obj, attr_name, export=True): write(f, s) f.close()
def render(self, context, instance, placeholder): if settings.CMS_DBGETTEXT: from dbgettext.parser import parsed_gettext instance.topic = parsed_gettext(instance, 'topic') instance.body = parsed_gettext(instance, 'body') context.update({ 'body': plugin_tags_to_user_html(instance.body, context, placeholder), 'topic': instance.topic, 'css': instance.get_css_display(), 'placeholder': placeholder, 'object': instance, }) return context
def render(self, context, instance, placeholder): if settings.CMS_DBGETTEXT: from dbgettext.parser import parsed_gettext #@UnresolvedImport instance.body = parsed_gettext(instance, 'body') context.update({ 'body': plugin_tags_to_user_html(instance.body, context, placeholder), 'placeholder': placeholder, 'object': instance }) self.render_template = Template(instance.body) return context