# HG changeset patch # User Marcin Kuzminski # Date 2017-01-12 15:06:06 # Node ID b418df09acf45a9067abdae0c5c024b72c9d7f51 # Parent 9a1b7bc40d0a50d8d2fe463867b5e59653eb48fb i18n: translate properly navList and also support proper translation into other admin views. diff --git a/rhodecode/admin/navigation.py b/rhodecode/admin/navigation.py --- a/rhodecode/admin/navigation.py +++ b/rhodecode/admin/navigation.py @@ -66,6 +66,15 @@ class NavEntry(object): else: return url(self.view_name) + def get_localized_name(self, request): + if hasattr(request, 'translate'): + return request.translate(self.name) + else: + # TODO(marcink): Remove this after migrating to pyramid + from pyramid.threadlocal import get_current_request + pyramid_request = get_current_request() + return pyramid_request.translate(self.name) + @implementer(IAdminNavigationRegistry) class NavigationRegistry(object): @@ -81,13 +90,11 @@ class NavigationRegistry(object): NavEntry('hooks', _('Hooks'), 'admin_settings_hooks'), NavEntry('search', _('Full Text Search'), 'admin_settings_search'), - NavEntry('integrations', _('Integrations'), 'global_integrations_home', pyramid=True), - NavEntry('system', _('System Info'), 'admin_settings_system'), - - - NavEntry('session', _('User Sessions'), + NavEntry('system', _('System Info'), + 'admin_settings_system', pyramid=True), + NavEntry('sessions', _('User Sessions'), 'admin_settings_sessions', pyramid=True), NavEntry('open_source', _('Open Source Licenses'), 'admin_settings_open_source', pyramid=True), @@ -97,8 +104,7 @@ class NavigationRegistry(object): # NavEntry('supervisor', _('Supervisor'), 'admin_settings_supervisor'), ] - _labs_entry = NavEntry('labs', _('Labs'), - 'admin_settings_labs') + _labs_entry = NavEntry('labs', _('Labs'), 'admin_settings_labs') def __init__(self, labs_active=False): self._registered_entries = collections.OrderedDict([ @@ -112,7 +118,8 @@ class NavigationRegistry(object): self._registered_entries[entry.key] = entry def get_navlist(self, request): - navlist = [NavListEntry(i.key, i.name, i.generate_url(request)) + navlist = [NavListEntry(i.key, i.get_localized_name(request), + i.generate_url(request)) for i in self._registered_entries.values()] return navlist diff --git a/rhodecode/admin/views/svn_config.py b/rhodecode/admin/views/svn_config.py --- a/rhodecode/admin/views/svn_config.py +++ b/rhodecode/admin/views/svn_config.py @@ -22,7 +22,6 @@ import logging from pyramid.view import view_config -from rhodecode.translation import _ from rhodecode.svn_support.utils import generate_mod_dav_svn_config from rhodecode.admin.views.base import AdminSettingsView @@ -41,6 +40,7 @@ class SvnConfigAdminSettingsView(AdminSe route_name='admin_settings_vcs_svn_generate_cfg', request_method='POST', renderer='json') def vcs_svn_generate_config(self): + _ = self.request.translate try: generate_mod_dav_svn_config(self.request.registry) msg = {