using new egw.langRequire to load translations only once (per top-window load)

This commit is contained in:
Ralf Becker 2012-03-14 12:10:31 +00:00
parent 19b3120be6
commit 2bbb3b07e9

View File

@ -105,16 +105,6 @@ class etemplate_new extends etemplate_widget_template
// Include the etemplate2 javascript code // Include the etemplate2 javascript code
egw_framework::validate_file('.', 'etemplate2', 'etemplate'); egw_framework::validate_file('.', 'etemplate2', 'etemplate');
// load translations
translation::add_app('etemplate');
foreach(translation::$loaded_apps as $app => $lang)
{
egw_framework::validate_file('/phpgwapi/lang.php', array(
'app' => $app,
'lang' => $lang,
));
}
if (!$this->rel_path) throw new egw_exception_assertion_failed('No (valid) template read!'); if (!$this->rel_path) throw new egw_exception_assertion_failed('No (valid) template read!');
// generate new etemplate request object // generate new etemplate request object
@ -163,9 +153,18 @@ class etemplate_new extends etemplate_widget_template
{ {
parse_navbar(); parse_navbar();
} }
// load translations
translation::add_app('etemplate');
$langRequire = array();
foreach(translation::$loaded_apps as $app => $lang)
{
$langRequire[] = array('app' => $app, 'lang' => $lang);
}
echo ' echo '
<div id="container"></div> <div id="container"></div>
<script> <script>
egw.langRequire(window, '.json_encode($langRequire).');
egw(window).ready(function() { egw(window).ready(function() {
var et2 = new etemplate2(document.getElementById("container"), "etemplate_new::ajax_process_content"); var et2 = new etemplate2(document.getElementById("container"), "etemplate_new::ajax_process_content");
et2.load("'.$GLOBALS['egw_info']['server']['webserver_url'].$this->rel_path.'",'.json_encode($data).'); et2.load("'.$GLOBALS['egw_info']['server']['webserver_url'].$this->rel_path.'",'.json_encode($data).');