# HG changeset patch # User RĂ©mi Cardona # Date 1413390234 -7200 # Node ID 326fbc5c92b0520316fccb853c9d5a62c9f31eb8 # Parent 292c81246347f045b0a2a0b6fc775c6a1fe2758d [web] Cache results from 'i18n' ajax controller (closes #4487856) This is a simple transient cache which will be forgotten as soon as the user leaves the current page. diff -r 292c81246347 -r 326fbc5c92b0 web/data/cubicweb.ajax.js --- a/web/data/cubicweb.ajax.js Wed Oct 15 17:29:29 2014 +0200 +++ b/web/data/cubicweb.ajax.js Wed Oct 15 18:23:54 2014 +0200 @@ -435,13 +435,21 @@ } //============= higher level AJAX functions using remote calls ===============// + +var _i18ncache = {}; + /** * .. function:: _(message) * * emulation of gettext's _ shortcut */ function _(message) { - return loadRemote(AJAX_BASE_URL, ajaxFuncArgs('i18n', null, [message]), 'GET', true)[0]; + var form; + if (!(message in _i18ncache)) { + form = ajaxFuncArgs('i18n', null, [message]); + _i18ncache[message] = loadRemote(AJAX_BASE_URL, form, 'GET', true)[0]; + } + return _i18ncache[message]; } /**