mirror of
https://github.com/postgres/pgweb.git
synced 2025-08-10 00:42:06 +00:00
Add a filter for getting language name from code
This adds a requirement on the Babel module in python.
This commit is contained in:
@ -8,6 +8,7 @@ import os
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import json
|
import json
|
||||||
import pynliner
|
import pynliner
|
||||||
|
import babel
|
||||||
|
|
||||||
register = template.Library()
|
register = template.Library()
|
||||||
|
|
||||||
@ -113,6 +114,14 @@ def list_templates(value):
|
|||||||
yield f.stem
|
yield f.stem
|
||||||
|
|
||||||
|
|
||||||
|
@register.filter()
|
||||||
|
def languagename(lang):
|
||||||
|
try:
|
||||||
|
return babel.Locale(lang).english_name
|
||||||
|
except Exception:
|
||||||
|
return lang
|
||||||
|
|
||||||
|
|
||||||
@register.simple_tag(takes_context=True)
|
@register.simple_tag(takes_context=True)
|
||||||
def git_changes_link(context):
|
def git_changes_link(context):
|
||||||
return mark_safe('<a href="https://git.postgresql.org/gitweb/?p=pgweb.git;a=history;f=templates/{}">View</a> change history.'.format(context.template_name))
|
return mark_safe('<a href="https://git.postgresql.org/gitweb/?p=pgweb.git;a=history;f=templates/{}">View</a> change history.'.format(context.template_name))
|
||||||
|
@ -8,3 +8,4 @@ cvss==2.1
|
|||||||
pytidylib==0.3.2
|
pytidylib==0.3.2
|
||||||
pycodestyle==2.4.0
|
pycodestyle==2.4.0
|
||||||
pynliner==0.8.0
|
pynliner==0.8.0
|
||||||
|
Babel=2.6.0
|
||||||
|
Reference in New Issue
Block a user