Commit d3d2a990 authored by Martin Matějek's avatar Martin Matějek

fixup! Refactoring of gettext translations

parent 9430c901
[jinja2: **.j2]
encoding = utf-8
[jinja2: **.yml]
encoding = utf-8
import gettext
import jinja2
import yaml
......@@ -55,7 +53,7 @@ class NotificationSkeleton:
for a in self.actions:
parsed = yaml.safe_load(self.jinja_plugin_template.render())
actions[a] = parsed['actions']['title']
actions[a] = parsed['actions'][a]['title']
return actions
......@@ -73,7 +71,10 @@ class NotificationSkeleton:
extensions=['jinja2.ext.i18n']
)
self.jinja_message_template = self.jinja_env.get_template(self.template['src'])
self.jinja_plugin_template = self.jinja_env.get_template(self.template['plugin_src'])
plugin_template = '{}.yml'.format(self.name)
print("plugin tpl: {}".format(plugin_template))
self.jinja_plugin_template = self.jinja_env.get_template(plugin_template)
def render(self, data, media_type, lang):
"""Render using jinja in given language"""
......
......@@ -106,7 +106,10 @@ class PluginStorage:
if attr in skeleton:
notification_args[attr] = skeleton[attr]
notification_args['template_dir'] = os.path.join(self.templates_dir, plugin_name)
notification_args['template_dir'] = [
os.path.join(self.templates_dir, plugin_name),
os.path.join(os.getcwd(), self.plugin_dir),
]
return NotificationSkeleton(**notification_args)
......
......@@ -3,7 +3,7 @@ width = 150
omit_header = True
mapping_file = babel.cfg
output_file = messages.pot
input_dirs = templates/
input_dirs = templates,plugins
[init_catalog]
input_file = messages.pot
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment