misc: turn /i18n.js into a pure django view (#59888)
This commit is contained in:
parent
70754d6b9b
commit
4fe9cd2f76
25
wcs/root.py
25
wcs/root.py
|
@ -261,7 +261,6 @@ class RootDirectory(Directory):
|
|||
'auth',
|
||||
'preview',
|
||||
'fargo',
|
||||
('i18n.js', 'i18n_js'),
|
||||
'static',
|
||||
'actions',
|
||||
]
|
||||
|
@ -426,30 +425,6 @@ class RootDirectory(Directory):
|
|||
# or a form ?
|
||||
return root.RootDirectory()._q_lookup(component)
|
||||
|
||||
def i18n_js(self):
|
||||
get_response().set_content_type('text/javascript')
|
||||
strings = {
|
||||
'confirmation': _('Are you sure?'),
|
||||
'file_type_error': _('Invalid file type'),
|
||||
'file_size_error': _('File size exceeds limits'),
|
||||
'geoloc_unknown_error': _('Geolocation: unknown error'),
|
||||
'geoloc_permission_denied': _('Geolocation: permission denied'),
|
||||
'geoloc_position_unavailable': _('Geolocation: position unavailable'),
|
||||
'geoloc_timeout': _('Geolocation: timeout'),
|
||||
'map_zoom_in': _('Zoom in'),
|
||||
'map_zoom_out': _('Zoom out'),
|
||||
'map_display_position': _('Display my position'),
|
||||
's2_errorloading': _('The results could not be loaded'),
|
||||
's2_nomatches': _('No matches found'),
|
||||
's2_tooshort': _('Please enter more characters'),
|
||||
's2_loadmore': _('Loading more results...'),
|
||||
's2_searching': _('Searching...'),
|
||||
'close': _('Close'),
|
||||
'email_domain_suggest': _('Did you want to write'),
|
||||
'email_domain_fix': _('Apply fix'),
|
||||
}
|
||||
return 'WCS_I18N = %s;\n' % json.dumps(strings, cls=misc.JSONEncoder)
|
||||
|
||||
admin = None
|
||||
backoffice = None
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ from .statistics import views as statistics_views
|
|||
|
||||
urlpatterns = [
|
||||
url(r'^robots.txt$', views.robots_txt),
|
||||
url(r'^i18n\.js$', views.i18n_js),
|
||||
url(r'^backoffice/', views.backoffice),
|
||||
url(r'^__provision__/$', api.provisionning),
|
||||
url(r'^api/validate-condition$', api.validate_condition, name='api-validate-condition'),
|
||||
|
|
30
wcs/views.py
30
wcs/views.py
|
@ -14,11 +14,13 @@
|
|||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import json
|
||||
|
||||
from django.http import HttpResponse
|
||||
from quixote import get_publisher, get_request, get_response
|
||||
|
||||
from . import compat
|
||||
from .qommon import template
|
||||
from .qommon import _, misc, template
|
||||
|
||||
|
||||
class Backoffice(compat.TemplateWithFallbackView):
|
||||
|
@ -61,6 +63,32 @@ class Backoffice(compat.TemplateWithFallbackView):
|
|||
backoffice = Backoffice.as_view()
|
||||
|
||||
|
||||
def i18n_js(request):
|
||||
strings = {
|
||||
'confirmation': _('Are you sure?'),
|
||||
'file_type_error': _('Invalid file type'),
|
||||
'file_size_error': _('File size exceeds limits'),
|
||||
'geoloc_unknown_error': _('Geolocation: unknown error'),
|
||||
'geoloc_permission_denied': _('Geolocation: permission denied'),
|
||||
'geoloc_position_unavailable': _('Geolocation: position unavailable'),
|
||||
'geoloc_timeout': _('Geolocation: timeout'),
|
||||
'map_zoom_in': _('Zoom in'),
|
||||
'map_zoom_out': _('Zoom out'),
|
||||
'map_display_position': _('Display my position'),
|
||||
's2_errorloading': _('The results could not be loaded'),
|
||||
's2_nomatches': _('No matches found'),
|
||||
's2_tooshort': _('Please enter more characters'),
|
||||
's2_loadmore': _('Loading more results...'),
|
||||
's2_searching': _('Searching...'),
|
||||
'close': _('Close'),
|
||||
'email_domain_suggest': _('Did you want to write'),
|
||||
'email_domain_fix': _('Apply fix'),
|
||||
}
|
||||
return HttpResponse(
|
||||
'WCS_I18N = %s;\n' % json.dumps(strings, cls=misc.JSONEncoder), content_type='application/javascript'
|
||||
)
|
||||
|
||||
|
||||
def robots_txt(request, *args, **kwargs):
|
||||
return HttpResponse(
|
||||
get_publisher().get_site_option('robots_txt', 'variables') or '', content_type='text/plain'
|
||||
|
|
Loading…
Reference in New Issue