Commit f00c03e1 authored by Sven Franck's avatar Sven Franck Committed by Xiaowu Zhang

erp5_web_renderjs_ui: add translation to core erp5_gadget

- switch gadget declarations in html (translate needs jio_ajax, must be available before header/panel)
- add translation method bridge
- add notifyUpdate to re-render header once translations are available
- add getSiteRoot to return root url, so translation gadget can fetch languages declared on website
- add error handlers to make sure existing rjs websites don't break
parent 412cf29b
......@@ -134,24 +134,23 @@
\n
</head>\n
<body>\n
<div data-gadget-url="gadget_jio.html"\n
data-gadget-scope="jio_gadget"\n
data-gadget-sandbox="public"></div>\n
\n
<div data-gadget-sandbox="public" \n
data-gadget-url="gadget_translate.html" \n
data-gadget-scope="translate"></div>\n
\n
<div data-gadget-url="gadget_erp5_header.html"\n
data-gadget-scope="header"\n
data-gadget-sandbox="public"></div>\n
\n
\n
<div data-gadget-url="gadget_erp5_panel.html"\n
data-gadget-scope="panel"\n
data-gadget-sandbox="public"></div>\n
\n
<article></article>\n
\n
<section data-gadget-url="gadget_jio.html"\n
data-gadget-scope="jio_gadget"\n
data-gadget-sandbox="public"></section>\n
\n
<section data-gadget-sandbox="public" \n
data-gadget-url="gadget_translate.html" \n
data-gadget-scope="translate"></section>\n
\n
</body>\n
</html>
......@@ -291,7 +290,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>939.52806.11840.43758</string> </value>
<value> <string>939.54300.9851.50329</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -309,7 +308,7 @@
</tuple>
<state>
<tuple>
<float>1419345029.51</float>
<float>1420034261.32</float>
<string>GMT</string>
</tuple>
</state>
......
......@@ -209,7 +209,6 @@
// Init local properties\n
.ready(function (g) {\n
g.props = {\n
frontpage_gadget: "gadget_erp5_pt_frontpage.html",\n
hateoas_url: "hateoas/",\n
action_view: "action_object_view",\n
default_view_reference: "view"\n
......@@ -233,16 +232,6 @@
g.props.article = element.querySelector("article");\n
});\n
})\n
\n
.ready(function (my_gadget) {\n
return new RSVP.Queue()\n
.push(function () {\n
return my_gadget.getDeclaredGadget("translate");\n
})\n
.push(function (my_translation_gadget) {\n
return my_translation_gadget.render();\n
});\n
})\n
\n
.ready(function (g) {\n
return g.getDeclaredGadget("header")\n
......@@ -269,19 +258,19 @@
);\n
});\n
})\n
.allowPublicAcquisition("translateStringList", function (param_list) {\n
.allowPublicAcquisition("getLanguageList", function (param_list) {\n
return this.getDeclaredGadget("translate")\n
.push(function (translation_gadget) {\n
return translation_gadget.translateStringList.apply(\n
return translation_gadget.getLanguageList.apply(\n
translation_gadget,\n
param_list\n
);\n
});\n
})\n
.allowPublicAcquisition("translateElementList", function (param_list) {\n
.allowPublicAcquisition("translateHtml", function (param_list) {\n
return this.getDeclaredGadget("translate")\n
.push(function (translation_gadget) {\n
return translation_gadget.translateElementList.apply(\n
return translation_gadget.translateHtml.apply(\n
translation_gadget,\n
param_list\n
);\n
......@@ -376,7 +365,18 @@
}\n
return displayError(this, param_list[0]);\n
})\n
\n
// XXX translate: while header calls render on ready, this is needed to\n
// update the header once translations are available\n
.allowPublicAcquisition(\'notifyUpdate\', function () {\n
return this.getDeclaredGadget("header")\n
.push(\n
function (header_gadget) {\n
return header_gadget.notifyUpdate();\n
},\n
function () {\n
return;\n
});\n
})\n
.allowPublicAcquisition(\'notifySubmitting\', function () {\n
return this.getDeclaredGadget("header")\n
.push(function (header_gadget) {\n
......@@ -408,10 +408,20 @@
return panel_gadget.toggle();\n
});\n
})\n
.allowPublicAcquisition(\'getSiteRoot\', function () {\n
return this.getSiteRoot();\n
})\n
\n
/////////////////////////////////////////////////////////////////\n
// declared methods\n
/////////////////////////////////////////////////////////////////\n
\n
// XXX translate: called before ready(), so props is not available.\n
// Needed to lookup to retrieve HAL to fetch site module/runner languages \n
.declareMethod(\'getSiteRoot\', function () {\n
return "hateoas/";\n
})\n
\n
// Render the page\n
.declareMethod(\'configure\', function (options) {\n
var key;\n
......@@ -666,7 +676,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>939.52807.26806.58419</string> </value>
<value> <string>940.1446.34871.22050</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -684,7 +694,7 @@
</tuple>
<state>
<tuple>
<float>1419345403.22</float>
<float>1420195841.19</float>
<string>GMT</string>
</tuple>
</state>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment