code: def setup(self, app):
          super().setup(app)
          self.handlers = OrderedDict()
          app.ps.jinja2.cfg.template_folders.append(op.join(PLUGIN_ROOT, 'templates'))
          @app.ps.jinja2.filter
          def admtest(value, a, b=None):
              return a if value else b
          @app.ps.jinja2.filter
          def admeq(a, b, result=True):
              return result if a == b else not result
          @app.ps.jinja2.register
          def admurl(request, prefix):
              qs = {k: v for k, v in request.query.items() if not k.startswith(prefix)}
              if not qs:
                  qs = {'ap': 0}
              return "%s?%s" % (request.path, urlparse.urlencode(qs))
          if self.cfg.name is None:
              self.cfg.name = "%s admin" % app.name.title()
          if not callable(self.cfg.home):
              def admin_home(request):
                  yield from self.authorize(request)
                  return app.ps.jinja2.render(self.cfg.template_home, active=None)
              self.cfg.home = admin_home
          app.register(self.cfg.prefix)(self.cfg.home)
          if not self.cfg.i18n:
              app.ps.jinja2.env.globals.update({
                  '_': lambda s: s,
                  'gettext': lambda s: s,
                  'ngettext': lambda s, p, n: (n != 1 and (p,) or (s,))[0],
              })
              return
          if 'babel' not in app.ps or not isinstance(app.ps.babel, BPlugin):
              raise PluginException(
                  'Plugin `%s` requires for plugin `%s` to be installed to the application.' % (
                      self.name, BPlugin))
          app.ps.babel.cfg.locales_dirs.append(op.join(PLUGIN_ROOT, 'locales'))
          if not app.ps.babel.locale_selector_func:
              app.ps.babel.locale_selector_func = app.ps.babel.select_locale_by_request