mirror of
https://github.com/postgres/pgweb.git
synced 2025-07-29 11:59:36 +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
|
||||
import json
|
||||
import pynliner
|
||||
import babel
|
||||
|
||||
register = template.Library()
|
||||
|
||||
@ -113,6 +114,14 @@ def list_templates(value):
|
||||
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)
|
||||
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))
|
||||
|
@ -8,3 +8,4 @@ cvss==2.1
|
||||
pytidylib==0.3.2
|
||||
pycodestyle==2.4.0
|
||||
pynliner==0.8.0
|
||||
Babel=2.6.0
|
||||
|
Reference in New Issue
Block a user