Commit 820671e1 authored by Serge S. Koval's avatar Serge S. Koval

Ability to override translations path.

parent c602b40b
...@@ -2,7 +2,21 @@ try: ...@@ -2,7 +2,21 @@ try:
from flask.ext.babel import Domain from flask.ext.babel import Domain
from flask.ext.adminex import translations from flask.ext.adminex import translations
domain = Domain(translations.__path__[0], domain='admin')
class CustomDomain(Domain):
def __init__(self):
super(CustomDomain, self).__init__(translations.__path__[0], domain='admin')
def get_translations_path(self, ctx):
print ctx
dirname = ctx.app.extensions['admin'].translations_path
if dirname is not None:
return dirname
return super(CustomDomain, self).get_translations_path(ctx)
domain = CustomDomain()
gettext = domain.gettext gettext = domain.gettext
ngettext = domain.ngettext ngettext = domain.ngettext
......
...@@ -276,7 +276,8 @@ class Admin(object): ...@@ -276,7 +276,8 @@ class Admin(object):
""" """
Collection of the views. Also manages menu structure. Collection of the views. Also manages menu structure.
""" """
def __init__(self, app=None, name=None, url=None, index_view=None): def __init__(self, app=None, name=None, url=None, index_view=None,
translations_path=None):
""" """
Constructor. Constructor.
...@@ -286,9 +287,14 @@ class Admin(object): ...@@ -286,9 +287,14 @@ class Admin(object):
Application name. Will be displayed in main menu and as a page title. If not provided, defaulted to "Admin" Application name. Will be displayed in main menu and as a page title. If not provided, defaulted to "Admin"
`index_view` `index_view`
Home page view to use. If not provided, will use `AdminIndexView`. Home page view to use. If not provided, will use `AdminIndexView`.
`translations_path`
Location of the translation message catalogs. By default will use translations
shipped with the Flask-AdminEx.
""" """
self.app = app self.app = app
self.translations_path = translations_path
self._views = [] self._views = []
self._menu = [] self._menu = []
self._menu_categories = dict() self._menu_categories = dict()
......
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