Commit a39b74c2 authored by Jérome Perrin's avatar Jérome Perrin

renderjs: update translation data in post-upgrade

Firstly, rework a bit the action to create translation data, the action no longer allow choosing the translation data script to update, but uses the one referenced in the translation gadget html.

In post upgrade, compare the actual content of the translation data script with the expected content, calculated from web site languages, data-i18n attributes from referenced pages and Localizer messages.

This makes the requirement that web sites with different configurations for translations need to use different translation gadget stronger, when it's not met post upgrade will always report consistency issues. To address this, modify existing web sites so that they all use different translation gadgets - or at least don't use translation gadget explicitly. 

This was made by:
 - all web sites by default do not have a translation gadget
 - smart_assistant use a dedicated translation gadget, to confirm that using a different translation gadget is possible with an officejs web site, where the translation gadget is defined in the "app" web section.
 - officejs_support_request_ui uses a dedicated translation gadget, because we need this for a customer project and for ourselves.
 - other web sites do not support translation by default, but enabling would be easy: 
    - set the allowed languages on web site
    - create an empty web script ( `{website}_translation_data.js` )
    - create a translation gadget web page ( `{website}_translation.html` ) using same content as `gadget_translation.html`, except that the translation data script should be the one created above ( `{website}_translation_data.js` )
    - configure the web site to use translation gadget in layout properties. In the case of an OfficeJS web site, this should not be set on the web site but on the main web section
    - use "Update Translation Data" action on web site or run post-upgrade step of upgrader.

This revealed problems (page does not load with javascript error) when using different translation gadgets, that were addressed by not pre-loading the default translation gadget.

See merge request nexedi/erp5!1151
parents 1833f952 da32220c
Pipeline #10199 passed with stage
in 0 seconds
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
var warmup_gadget_done = false, var warmup_gadget_done = false,
warmup_list = [ warmup_list = [
'gadget_erp5_label_field.html', 'gadget_erp5_label_field.html',
'gadget_translation.html',
'gadget_erp5_header.html', 'gadget_erp5_header.html',
'gadget_erp5_ojs_panel.html', 'gadget_erp5_ojs_panel.html',
'gadget_html5_input.html', 'gadget_html5_input.html',
......
...@@ -258,8 +258,8 @@ ...@@ -258,8 +258,8 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1575297418.87</float> <float>1592203174.96</float>
<string>UTC</string> <string>GMT+2</string>
</tuple> </tuple>
</state> </state>
</object> </object>
......
/**
* This translation data is generated automatically and updated with upgrader in post-upgarde.
* Do not edit manually, but use "Update Translation Data" action on web site to update from
* Localizer and from data-i18n tags on web pages.
*/
/*globals window*/
/*jslint indent: 2, nomen: true */
(function (window) {
"use strict";
// @ts-ignore
window.translation_data = {
"en": {
}
};
}(window));
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>OfficeJS Smart Assistant Translation Gadget</title>
<link rel="http://www.renderjs.org/rel/interface" href="interface_translation.html">
<!-- renderjs -->
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<!-- custom script -->
<script src="gadget_officejs_smart_assistant_translation_data.js" type="text/javascript"></script>
<script src="gadget_translation.js" type="text/javascript"></script>
</head>
<body>
</body>
</html>
...@@ -249,16 +249,6 @@ ...@@ -249,16 +249,6 @@
<value> <string>string</string> </value> <value> <string>string</string> </value>
</item> </item>
</dictionary> </dictionary>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>configuration_translation_gadget_url</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
<dictionary> <dictionary>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
...@@ -469,10 +459,6 @@ ...@@ -469,10 +459,6 @@
<none/> <none/>
</value> </value>
</item> </item>
<item>
<key> <string>configuration_translation_gadget_url</string> </key>
<value> <string>gadget_translation.html</string> </value>
</item>
<item> <item>
<key> <string>configuration_view_action_category</string> </key> <key> <string>configuration_view_action_category</string> </key>
<value> <value>
......
...@@ -249,16 +249,6 @@ ...@@ -249,16 +249,6 @@
<value> <string>string</string> </value> <value> <string>string</string> </value>
</item> </item>
</dictionary> </dictionary>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>configuration_translation_gadget_url</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
<dictionary> <dictionary>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
...@@ -493,10 +483,6 @@ ...@@ -493,10 +483,6 @@
<none/> <none/>
</value> </value>
</item> </item>
<item>
<key> <string>configuration_translation_gadget_url</string> </key>
<value> <string>gadget_translation.html</string> </value>
</item>
<item> <item>
<key> <string>configuration_view_action_category</string> </key> <key> <string>configuration_view_action_category</string> </key>
<value> <value>
......
...@@ -209,16 +209,6 @@ ...@@ -209,16 +209,6 @@
<value> <string>string</string> </value> <value> <string>string</string> </value>
</item> </item>
</dictionary> </dictionary>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>configuration_translation_gadget_url</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
<dictionary> <dictionary>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
...@@ -425,10 +415,6 @@ WebSection_getCodemirrorEditorPrecacheManifestList</string> </value> ...@@ -425,10 +415,6 @@ WebSection_getCodemirrorEditorPrecacheManifestList</string> </value>
<none/> <none/>
</value> </value>
</item> </item>
<item>
<key> <string>configuration_translation_gadget_url</string> </key>
<value> <string>gadget_translation.html</string> </value>
</item>
<item> <item>
<key> <string>configuration_webapp_manifest_url</string> </key> <key> <string>configuration_webapp_manifest_url</string> </key>
<value> <string>gadget_officejs_json_manifest_javascript_editor.json</string> </value> <value> <string>gadget_officejs_json_manifest_javascript_editor.json</string> </value>
......
...@@ -249,26 +249,6 @@ ...@@ -249,26 +249,6 @@
<value> <string>string</string> </value> <value> <string>string</string> </value>
</item> </item>
</dictionary> </dictionary>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>configuration_translation_gadget_url</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>configuration_manifest_url</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
<dictionary> <dictionary>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
...@@ -447,10 +427,6 @@ ...@@ -447,10 +427,6 @@
<key> <string>configuration_latest_version</string> </key> <key> <string>configuration_latest_version</string> </key>
<value> <string>development</string> </value> <value> <string>development</string> </value>
</item> </item>
<item>
<key> <string>configuration_manifest_url</string> </key>
<value> <string>gadget_officejs.appcache</string> </value>
</item>
<item> <item>
<key> <string>configuration_panel_gadget_url</string> </key> <key> <string>configuration_panel_gadget_url</string> </key>
<value> <string>gadget_officejs_application_panel.html</string> </value> <value> <string>gadget_officejs_application_panel.html</string> </value>
...@@ -469,10 +445,6 @@ ...@@ -469,10 +445,6 @@
<none/> <none/>
</value> </value>
</item> </item>
<item>
<key> <string>configuration_translation_gadget_url</string> </key>
<value> <string>gadget_translation.html</string> </value>
</item>
<item> <item>
<key> <string>configuration_view_action_category</string> </key> <key> <string>configuration_view_action_category</string> </key>
<value> <value>
......
...@@ -209,16 +209,6 @@ ...@@ -209,16 +209,6 @@
<value> <string>string</string> </value> <value> <string>string</string> </value>
</item> </item>
</dictionary> </dictionary>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>configuration_translation_gadget_url</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
<dictionary> <dictionary>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
...@@ -309,10 +299,6 @@ ...@@ -309,10 +299,6 @@
<key> <string>configuration_router_gadget_url</string> </key> <key> <string>configuration_router_gadget_url</string> </key>
<value> <string>gadget_officejs_crib_router.html</string> </value> <value> <string>gadget_officejs_crib_router.html</string> </value>
</item> </item>
<item>
<key> <string>configuration_translation_gadget_url</string> </key>
<value> <string>gadget_translation.html</string> </value>
</item>
<item> <item>
<key> <string>configuration_x_frame_options</string> </key> <key> <string>configuration_x_frame_options</string> </key>
<value> <string>SAMEORIGIN</string> </value> <value> <string>SAMEORIGIN</string> </value>
......
...@@ -249,16 +249,6 @@ ...@@ -249,16 +249,6 @@
<value> <string>string</string> </value> <value> <string>string</string> </value>
</item> </item>
</dictionary> </dictionary>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>configuration_translation_gadget_url</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
<dictionary> <dictionary>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
...@@ -469,10 +459,6 @@ ...@@ -469,10 +459,6 @@
<none/> <none/>
</value> </value>
</item> </item>
<item>
<key> <string>configuration_translation_gadget_url</string> </key>
<value> <string>gadget_translation.html</string> </value>
</item>
<item> <item>
<key> <string>configuration_view_action_category</string> </key> <key> <string>configuration_view_action_category</string> </key>
<value> <value>
......
...@@ -249,16 +249,6 @@ ...@@ -249,16 +249,6 @@
<value> <string>string</string> </value> <value> <string>string</string> </value>
</item> </item>
</dictionary> </dictionary>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>configuration_translation_gadget_url</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
<dictionary> <dictionary>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
...@@ -469,10 +459,6 @@ ...@@ -469,10 +459,6 @@
<none/> <none/>
</value> </value>
</item> </item>
<item>
<key> <string>configuration_translation_gadget_url</string> </key>
<value> <string>gadget_translation.html</string> </value>
</item>
<item> <item>
<key> <string>configuration_view_action_category</string> </key> <key> <string>configuration_view_action_category</string> </key>
<value> <value>
......
...@@ -249,26 +249,6 @@ ...@@ -249,26 +249,6 @@
<value> <string>string</string> </value> <value> <string>string</string> </value>
</item> </item>
</dictionary> </dictionary>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>configuration_translation_gadget_url</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>configuration_manifest_url</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
<dictionary> <dictionary>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
...@@ -457,10 +437,6 @@ ...@@ -457,10 +437,6 @@
<key> <string>configuration_latest_version</string> </key> <key> <string>configuration_latest_version</string> </key>
<value> <string>app</string> </value> <value> <string>app</string> </value>
</item> </item>
<item>
<key> <string>configuration_manifest_url</string> </key>
<value> <string>gadget_officejs.appcache</string> </value>
</item>
<item> <item>
<key> <string>configuration_panel_gadget_url</string> </key> <key> <string>configuration_panel_gadget_url</string> </key>
<value> <string>gadget_officejs_application_panel.html</string> </value> <value> <string>gadget_officejs_application_panel.html</string> </value>
...@@ -479,10 +455,6 @@ ...@@ -479,10 +455,6 @@
<none/> <none/>
</value> </value>
</item> </item>
<item>
<key> <string>configuration_translation_gadget_url</string> </key>
<value> <string>gadget_translation.html</string> </value>
</item>
<item> <item>
<key> <string>configuration_view_action_category</string> </key> <key> <string>configuration_view_action_category</string> </key>
<value> <value>
......
...@@ -249,16 +249,6 @@ ...@@ -249,16 +249,6 @@
<value> <string>string</string> </value> <value> <string>string</string> </value>
</item> </item>
</dictionary> </dictionary>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>configuration_translation_gadget_url</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
<dictionary> <dictionary>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
...@@ -479,10 +469,6 @@ ...@@ -479,10 +469,6 @@
<none/> <none/>
</value> </value>
</item> </item>
<item>
<key> <string>configuration_translation_gadget_url</string> </key>
<value> <string>gadget_translation.html</string> </value>
</item>
<item> <item>
<key> <string>configuration_view_action_category</string> </key> <key> <string>configuration_view_action_category</string> </key>
<value> <value>
......
...@@ -249,16 +249,6 @@ ...@@ -249,16 +249,6 @@
<value> <string>string</string> </value> <value> <string>string</string> </value>
</item> </item>
</dictionary> </dictionary>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>configuration_translation_gadget_url</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
<dictionary> <dictionary>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
...@@ -475,10 +465,6 @@ ...@@ -475,10 +465,6 @@
<none/> <none/>
</value> </value>
</item> </item>
<item>
<key> <string>configuration_translation_gadget_url</string> </key>
<value> <string>gadget_translation.html</string> </value>
</item>
<item> <item>
<key> <string>configuration_view_action_category</string> </key> <key> <string>configuration_view_action_category</string> </key>
<value> <value>
......
...@@ -391,9 +391,7 @@ WebSection_getSmartAssistantPrecacheManifestList</string> </value> ...@@ -391,9 +391,7 @@ WebSection_getSmartAssistantPrecacheManifestList</string> </value>
</item> </item>
<item> <item>
<key> <string>configuration_translation_gadget_url</string> </key> <key> <string>configuration_translation_gadget_url</string> </key>
<value> <value> <string>gadget_officejs_smart_assistant_translation.html</string> </value>
<none/>
</value>
</item> </item>
<item> <item>
<key> <string>configuration_webapp_manifest</string> </key> <key> <string>configuration_webapp_manifest</string> </key>
...@@ -664,8 +662,8 @@ WebSection_getSmartAssistantPrecacheManifestList</string> </value> ...@@ -664,8 +662,8 @@ WebSection_getSmartAssistantPrecacheManifestList</string> </value>
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1587729410.45</float> <float>1592182961.5</float>
<string>UTC</string> <string>GMT+2</string>
</tuple> </tuple>
</state> </state>
</object> </object>
......
...@@ -249,16 +249,6 @@ ...@@ -249,16 +249,6 @@
<value> <string>string</string> </value> <value> <string>string</string> </value>
</item> </item>
</dictionary> </dictionary>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>configuration_translation_gadget_url</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
<dictionary> <dictionary>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
...@@ -479,10 +469,6 @@ ...@@ -479,10 +469,6 @@
<none/> <none/>
</value> </value>
</item> </item>
<item>
<key> <string>configuration_translation_gadget_url</string> </key>
<value> <string>gadget_translation.html</string> </value>
</item>
<item> <item>
<key> <string>configuration_view_action_category</string> </key> <key> <string>configuration_view_action_category</string> </key>
<value> <value>
......
...@@ -249,16 +249,6 @@ ...@@ -249,16 +249,6 @@
<value> <string>string</string> </value> <value> <string>string</string> </value>
</item> </item>
</dictionary> </dictionary>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>configuration_translation_gadget_url</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
<dictionary> <dictionary>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
...@@ -479,10 +469,6 @@ ...@@ -479,10 +469,6 @@
<none/> <none/>
</value> </value>
</item> </item>
<item>
<key> <string>configuration_translation_gadget_url</string> </key>
<value> <string>gadget_translation.html</string> </value>
</item>
<item> <item>
<key> <string>configuration_view_action_category</string> </key> <key> <string>configuration_view_action_category</string> </key>
<value> <value>
......
...@@ -249,26 +249,6 @@ ...@@ -249,26 +249,6 @@
<value> <string>string</string> </value> <value> <string>string</string> </value>
</item> </item>
</dictionary> </dictionary>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>configuration_translation_gadget_url</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>configuration_manifest_url</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
<dictionary> <dictionary>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
...@@ -457,10 +437,6 @@ ...@@ -457,10 +437,6 @@
<key> <string>configuration_latest_version</string> </key> <key> <string>configuration_latest_version</string> </key>
<value> <string>app</string> </value> <value> <string>app</string> </value>
</item> </item>
<item>
<key> <string>configuration_manifest_url</string> </key>
<value> <string>gadget_officejs.appcache</string> </value>
</item>
<item> <item>
<key> <string>configuration_panel_gadget_url</string> </key> <key> <string>configuration_panel_gadget_url</string> </key>
<value> <string>gadget_officejs_application_panel.html</string> </value> <value> <string>gadget_officejs_application_panel.html</string> </value>
...@@ -479,10 +455,6 @@ ...@@ -479,10 +455,6 @@
<none/> <none/>
</value> </value>
</item> </item>
<item>
<key> <string>configuration_translation_gadget_url</string> </key>
<value> <string>gadget_translation.html</string> </value>
</item>
<item> <item>
<key> <string>configuration_view_action_category</string> </key> <key> <string>configuration_view_action_category</string> </key>
<value> <value>
......
...@@ -20,9 +20,9 @@ url_list = [ ...@@ -20,9 +20,9 @@ url_list = [
"gadget_jio.js", "gadget_jio.js",
"gadget_translate.html", "gadget_translate.html",
"gadget_translate.js", "gadget_translate.js",
"gadget_translation.html", "gadget_officejs_smart_assistant_translation.html",
"gadget_translation.js", "gadget_translation.js",
"gadget_translation_data.js", "gadget_officejs_smart_assistant_translation_data.js",
"gadget_erp5_editor_panel.html", "gadget_erp5_editor_panel.html",
"gadget_erp5_editor_panel.js", "gadget_erp5_editor_panel.js",
"gadget_erp5_ojs_panel.html", "gadget_erp5_ojs_panel.html",
......
...@@ -199,16 +199,6 @@ ...@@ -199,16 +199,6 @@
<value> <string>string</string> </value> <value> <string>string</string> </value>
</item> </item>
</dictionary> </dictionary>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>configuration_translation_gadget_url</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
<dictionary> <dictionary>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
...@@ -403,10 +393,6 @@ ...@@ -403,10 +393,6 @@
<key> <string>configuration_service_worker_url</string> </key> <key> <string>configuration_service_worker_url</string> </key>
<value> <string>gadget_erp5_serviceworker.js</string> </value> <value> <string>gadget_erp5_serviceworker.js</string> </value>
</item> </item>
<item>
<key> <string>configuration_translation_gadget_url</string> </key>
<value> <string>gadget_translation.html</string> </value>
</item>
<item> <item>
<key> <string>configuration_view_action_category</string> </key> <key> <string>configuration_view_action_category</string> </key>
<value> <string>object_view</string> </value> <value> <string>object_view</string> </value>
......
...@@ -204,16 +204,6 @@ ...@@ -204,16 +204,6 @@
<value> <string>string</string> </value> <value> <string>string</string> </value>
</item> </item>
</dictionary> </dictionary>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>configuration_translation_gadget_url</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
<dictionary> <dictionary>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
...@@ -310,10 +300,6 @@ ...@@ -310,10 +300,6 @@
<key> <string>configuration_panel_gadget_url</string> </key> <key> <string>configuration_panel_gadget_url</string> </key>
<value> <string>gadget_ojs_appstore_panel.html</string> </value> <value> <string>gadget_ojs_appstore_panel.html</string> </value>
</item> </item>
<item>
<key> <string>configuration_translation_gadget_url</string> </key>
<value> <string>gadget_translation.html</string> </value>
</item>
<item> <item>
<key> <string>configuration_view_action_category</string> </key> <key> <string>configuration_view_action_category</string> </key>
<value> <string>object_view</string> </value> <value> <string>object_view</string> </value>
......
...@@ -249,16 +249,6 @@ ...@@ -249,16 +249,6 @@
<value> <string>string</string> </value> <value> <string>string</string> </value>
</item> </item>
</dictionary> </dictionary>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>configuration_translation_gadget_url</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
<dictionary> <dictionary>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
...@@ -479,10 +469,6 @@ ...@@ -479,10 +469,6 @@
<none/> <none/>
</value> </value>
</item> </item>
<item>
<key> <string>configuration_translation_gadget_url</string> </key>
<value> <string>gadget_translation.html</string> </value>
</item>
<item> <item>
<key> <string>configuration_view_action_category</string> </key> <key> <string>configuration_view_action_category</string> </key>
<value> <value>
......
...@@ -249,16 +249,6 @@ ...@@ -249,16 +249,6 @@
<value> <string>string</string> </value> <value> <string>string</string> </value>
</item> </item>
</dictionary> </dictionary>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>configuration_translation_gadget_url</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
<dictionary> <dictionary>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
...@@ -479,10 +469,6 @@ ...@@ -479,10 +469,6 @@
<none/> <none/>
</value> </value>
</item> </item>
<item>
<key> <string>configuration_translation_gadget_url</string> </key>
<value> <string>gadget_translation.html</string> </value>
</item>
<item> <item>
<key> <string>configuration_view_action_category</string> </key> <key> <string>configuration_view_action_category</string> </key>
<value> <value>
......
...@@ -249,16 +249,6 @@ ...@@ -249,16 +249,6 @@
<value> <string>string</string> </value> <value> <string>string</string> </value>
</item> </item>
</dictionary> </dictionary>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>configuration_translation_gadget_url</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
<dictionary> <dictionary>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
...@@ -465,10 +455,6 @@ ...@@ -465,10 +455,6 @@
<none/> <none/>
</value> </value>
</item> </item>
<item>
<key> <string>configuration_translation_gadget_url</string> </key>
<value> <string>gadget_translation.html</string> </value>
</item>
<item> <item>
<key> <string>configuration_view_action_category</string> </key> <key> <string>configuration_view_action_category</string> </key>
<value> <value>
......
...@@ -249,16 +249,6 @@ ...@@ -249,16 +249,6 @@
<value> <string>string</string> </value> <value> <string>string</string> </value>
</item> </item>
</dictionary> </dictionary>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>configuration_translation_gadget_url</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
<dictionary> <dictionary>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
...@@ -465,10 +455,6 @@ ...@@ -465,10 +455,6 @@
<none/> <none/>
</value> </value>
</item> </item>
<item>
<key> <string>configuration_translation_gadget_url</string> </key>
<value> <string>gadget_translation.html</string> </value>
</item>
<item> <item>
<key> <string>configuration_view_action_category</string> </key> <key> <string>configuration_view_action_category</string> </key>
<value> <value>
......
...@@ -249,16 +249,6 @@ ...@@ -249,16 +249,6 @@
<value> <string>string</string> </value> <value> <string>string</string> </value>
</item> </item>
</dictionary> </dictionary>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>configuration_translation_gadget_url</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
<dictionary> <dictionary>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
...@@ -465,10 +455,6 @@ ...@@ -465,10 +455,6 @@
<none/> <none/>
</value> </value>
</item> </item>
<item>
<key> <string>configuration_translation_gadget_url</string> </key>
<value> <string>gadget_translation.html</string> </value>
</item>
<item> <item>
<key> <string>configuration_view_action_category</string> </key> <key> <string>configuration_view_action_category</string> </key>
<value> <value>
......
/**
* This translation data is generated automatically and updated with upgrader in post-upgarde.
* Do not edit manually, but use "Update Translation Data" action on web site to update from
* Localizer and from data-i18n tags on web pages.
*/
/*globals window*/
/*jslint indent: 2, nomen: true */
(function (window) {
"use strict";
// @ts-ignore
window.translation_data = {
"en": {
}
};
}(window));
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>Support Request Translation Gadget</title>
<link rel="http://www.renderjs.org/rel/interface" href="interface_translation.html">
<!-- renderjs -->
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<!-- custom script -->
<script src="gadget_supportrequest_translation_data.js" type="text/javascript"></script>
<script src="gadget_translation.js" type="text/javascript"></script>
</head>
<body>
</body>
</html>
...@@ -405,7 +405,7 @@ WebSection_getOfficeJSSupportRequestPrecacheManifestList</string> </value> ...@@ -405,7 +405,7 @@ WebSection_getOfficeJSSupportRequestPrecacheManifestList</string> </value>
</item> </item>
<item> <item>
<key> <string>configuration_translation_gadget_url</string> </key> <key> <string>configuration_translation_gadget_url</string> </key>
<value> <string>gadget_translation.html</string> </value> <value> <string>gadget_supportrequest_translation.html</string> </value>
</item> </item>
<item> <item>
<key> <string>configuration_view_action_category</string> </key> <key> <string>configuration_view_action_category</string> </key>
......
...@@ -126,9 +126,6 @@ handlebars.js\n ...@@ -126,9 +126,6 @@ handlebars.js\n
jiodev.js\n jiodev.js\n
renderjs.js\n renderjs.js\n
rsvp.js\n rsvp.js\n
gadget_translation.html\n
gadget_translation.js\n
gadget_translation_data.js\n
gadget_erp5_router.html\n gadget_erp5_router.html\n
gadget_erp5_router.js\n gadget_erp5_router.js\n
gadget_erp5_notification.html\n gadget_erp5_notification.html\n
......
...@@ -169,16 +169,6 @@ ...@@ -169,16 +169,6 @@
<value> <string>string</string> </value> <value> <string>string</string> </value>
</item> </item>
</dictionary> </dictionary>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>configuration_translation_gadget_url</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
<dictionary> <dictionary>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
...@@ -371,10 +361,6 @@ ...@@ -371,10 +361,6 @@
<key> <string>configuration_stylesheet_url</string> </key> <key> <string>configuration_stylesheet_url</string> </key>
<value> <string>gadget_jabberclient.css</string> </value> <value> <string>gadget_jabberclient.css</string> </value>
</item> </item>
<item>
<key> <string>configuration_translation_gadget_url</string> </key>
<value> <string>gadget_translation.html</string> </value>
</item>
<item> <item>
<key> <string>configuration_webapp_manifest_url</string> </key> <key> <string>configuration_webapp_manifest_url</string> </key>
<value> <value>
......
...@@ -213,16 +213,6 @@ ...@@ -213,16 +213,6 @@
<value> <string>string</string> </value> <value> <string>string</string> </value>
</item> </item>
</dictionary> </dictionary>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>configuration_translation_gadget_url</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
<dictionary> <dictionary>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
...@@ -345,10 +335,6 @@ ...@@ -345,10 +335,6 @@
<key> <string>configuration_router_gadget_url</string> </key> <key> <string>configuration_router_gadget_url</string> </key>
<value> <string>gadget_officejs_monitoring_router.html</string> </value> <value> <string>gadget_officejs_monitoring_router.html</string> </value>
</item> </item>
<item>
<key> <string>configuration_translation_gadget_url</string> </key>
<value> <string>gadget_translation.html</string> </value>
</item>
<item> <item>
<key> <string>configuration_x_frame_options</string> </key> <key> <string>configuration_x_frame_options</string> </key>
<value> <string>ALLOW-FROM-ALL</string> </value> <value> <string>ALLOW-FROM-ALL</string> </value>
......
...@@ -199,16 +199,6 @@ ...@@ -199,16 +199,6 @@
<value> <string>string</string> </value> <value> <string>string</string> </value>
</item> </item>
</dictionary> </dictionary>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>configuration_translation_gadget_url</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
<dictionary> <dictionary>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
...@@ -390,10 +380,6 @@ WebSection_getWebProjectPrecacheManifestList</string> </value> ...@@ -390,10 +380,6 @@ WebSection_getWebProjectPrecacheManifestList</string> </value>
<key> <string>configuration_service_worker_url</string> </key> <key> <string>configuration_service_worker_url</string> </key>
<value> <string>gadget_erp5_serviceworker.js</string> </value> <value> <string>gadget_erp5_serviceworker.js</string> </value>
</item> </item>
<item>
<key> <string>configuration_translation_gadget_url</string> </key>
<value> <string>gadget_translation.html</string> </value>
</item>
<item> <item>
<key> <string>configuration_view_action_category</string> </key> <key> <string>configuration_view_action_category</string> </key>
<value> <string>object_view</string> </value> <value> <string>object_view</string> </value>
......
...@@ -60,7 +60,7 @@ ...@@ -60,7 +60,7 @@
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
<value> <string>Create Translation Data</string> </value> <value> <string>Update Translation Data</string> </value>
</item> </item>
<item> <item>
<key> <string>visible</string> </key> <key> <string>visible</string> </key>
...@@ -77,7 +77,7 @@ ...@@ -77,7 +77,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>text</string> </key> <key> <string>text</string> </key>
<value> <string>string:${object_url}/WebSite_createTranslationData</string> </value> <value> <string>string:${object_url}/WebSite_viewUpdateTranslationDataDialog</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -17,8 +17,6 @@ and handling data send&receive. ...@@ -17,8 +17,6 @@ and handling data send&receive.
'gadget_erp5_form.html', 'gadget_erp5_form.html',
'gadget_erp5_field_float.html', 'gadget_erp5_field_float.html',
'gadget_erp5_field_listbox.html', 'gadget_erp5_field_listbox.html',
// Used in panel
'gadget_translation.html',
'gadget_erp5_panel.html', 'gadget_erp5_panel.html',
'gadget_erp5_header.html', 'gadget_erp5_header.html',
'gadget_erp5_searchfield.html', 'gadget_erp5_searchfield.html',
......
/**
* This translation data is generated automatically and updated with upgrader in post-upgarde.
* Do not edit manually, but use "Update Translation Data" action on web site to update from
* Localizer and from data-i18n tags on web pages.
*/
/*globals window*/ /*globals window*/
/*jslint indent: 2, nomen: true, maxlen: 80*/ /*jslint indent: 2, nomen: true */
(function (window) { (function (window) {
"use strict"; "use strict";
// @ts-ignore
window.translation_data = { window.translation_data = {
en: { "en": {
} }
}; };
}(window)); }(window));
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Script Constraint" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_identity_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_range_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>constraint_type/post_upgrade</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>translation_signature_constraint</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Script Constraint</string> </value>
</item>
<item>
<key> <string>script_id</string> </key>
<value> <string>WebSite_checkTranslationConsistency</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
"""Check that RenderJS translation gadget data is up to date.
This compare the current content of the translation gadget data against what
the content would be if "Update Translation Data" were used. If the scripts
are different, update the translation data to fix.
"""
from collections import defaultdict
if not context.getAvailableLanguageList():
return []
if context.getSkinSelectionName() != 'RJS':
return []
# find the .js containing translation data
gadget_translation_data_js = context.WebSite_getTranslationDataWebScriptValue()
if gadget_translation_data_js is None:
return []
error_list = []
if context.WebSite_getTranslationDataTextContent(
) != gadget_translation_data_js.getTextContent():
error_list.append("Translation data script content is not up to date")
if fixit:
# try to detect the case of two incompatible web sites configured for the same translation gadget.
# Use a mapping of set of web site ids keyed by translation data script reference and check
# if we update the same translation data script more than once in the same REQUEST.
# Using REQUEST is not really good, since upgrader uses grouped activities and we can just check
# web sites processed in the same activity group, but that's easy and hopefully better than nothing.
already_updated_websites = container.REQUEST.get(
script.getId(), defaultdict(set))
container.REQUEST.set(script.getId(), already_updated_websites)
gadget_translation_data_js_reference = gadget_translation_data_js.getReference()
already_updated_websites[gadget_translation_data_js_reference].add(context.getId())
if len(already_updated_websites[gadget_translation_data_js_reference]) > 1:
raise RuntimeError(
"Translation script %s is used by more than one web site with different configurations (%s)"
% (
gadget_translation_data_js_reference,
", ".join(already_updated_websites[gadget_translation_data_js_reference]),
))
context.WebSite_updateTranslationData()
# since we might have modified some cached files, check again the modification date
# consistency.
error_list.extend(
context.WebSite_checkCacheModificationDateConsistency(fixit=True))
return error_list
...@@ -50,11 +50,11 @@ ...@@ -50,11 +50,11 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string> translation_data_file, batch_mode=0</string> </value> <value> <string>fixit=False</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>Base_createTranslateData</string> </value> <value> <string>WebSite_checkTranslationConsistency</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>first_item</string>
<string>items</string>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>your_translation_data_file</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>first_item</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>items</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_list_field</string> </value>
</item>
<item>
<key> <string>first_item</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>items</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Translation Data File</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: [ (x,x) for x in here.Base_getTranslationSourceFileList()]</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
"""Returns the `text_content` that should be set on the translation data script for this RJS website.
"""
import re import re
import json import json
portal = context.getPortalObject() portal = context.getPortalObject()
Base_translateString = context.Base_translateString Base_translateString = context.Base_translateString
#(data-i18n)=["']{{((?:.(?!["']?(?:\S+)=|[>"']))+.)}}["']
attribute_filter_re = re.compile(r"""(data-i18n)=["']?((?:.(?!["']?\s+(?:\S+)=|[>"']))+.)["']?""")
translate_word = []
# Collect all translatable messages from web pages referenced by this web sites.
# The convention is to use data-i18n tags in HTML, like:
# <span data-18n="The message">The message</span>
# or in comments, like this:
# <!-- data-i18n="The message" -->
attribute_filter_re = re.compile(r"""(data-i18n)=["']?((?:.(?!["']?\s+(?:\S+)=|[>"']))+.)["']?""")
translatable_message_set = set([])
for web_page in portal.web_page_module.searchFolder(portal_type='Web Page', for web_page in portal.web_page_module.searchFolder(portal_type='Web Page',
reference=context.Base_getTranslationSourceFileList(only_html=1)): reference=context.Base_getTranslationSourceFileList(only_html=1)):
data = attribute_filter_re.findall(web_page.getTextContent()) data = attribute_filter_re.findall(web_page.getTextContent())
...@@ -16,38 +20,31 @@ for web_page in portal.web_page_module.searchFolder(portal_type='Web Page', ...@@ -16,38 +20,31 @@ for web_page in portal.web_page_module.searchFolder(portal_type='Web Page',
a = re.sub(r'[{|}]', "", attribute[1]) a = re.sub(r'[{|}]', "", attribute[1])
a = re.sub(r'\[.*?\]', "", a) a = re.sub(r'\[.*?\]', "", a)
if a: if a:
translate_word.append(a) translatable_message_set.add(a)
translate_word = list(set(translate_word))
language_list = context.getAvailableLanguageSet()
content = """
/*globals window*/\n
/*jslint indent: 2, nomen: true, maxlen: 80*/\n
(function (window) {\n
"use strict";\n
"""
tmp = {} tmp = {}
for language in context.getAvailableLanguageSet():
for language in language_list:
tmp[language] = {} tmp[language] = {}
for word in translate_word: for word in translatable_message_set:
tmp[language][word] = Base_translateString(word, lang = language) tmp[language][word] = Base_translateString(word, lang = language)
return """/**
* This translation data is generated automatically and updated with upgrader in post-upgarde.
content += " window.translation_data = " + json.dumps(tmp, indent=3, ensure_ascii=False, separators=(',', ': ')) * Do not edit manually, but use "Update Translation Data" action on web site to update from
content += ";\n}(window));" * Localizer and from data-i18n tags on web pages.
#return json.dumps(tmp, indent=3, ensure_ascii=False, separators=(',', ': ')) */
translation_data_file=context.web_page_module.searchFolder(portal_type='Web Script',reference=translation_data_file)[0] /*globals window*/
translation_data_file.edit(text_content = content) /*jslint indent: 2, nomen: true */
# Edit web section modification date (function (window) {
context.edit() "use strict";
// @ts-ignore
if batch_mode: window.translation_data = %s;
return 'done' }(window));
return context.Base_redirect('view', keep_items=dict(portal_status_message=Base_translateString("Translation Data Create"))) """ % ("\n ".join(
json.dumps(
tmp,
sort_keys=True,
indent=2,
ensure_ascii=False,
separators=(',', ': ')).splitlines()))
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>WebSite_getTranslationDataTextContent</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
# type: () -> Optional[erp5.portal_type.WebScript]
"""Returns the web script used to contain the translation data for this RJS web site.
"""
# OfficeJS is a bit more complex, the translation gadget is defined on the
# `app` web section, which is defined in "configuration_latest_version"
officejs_latest_version = context.getLayoutProperty(
"configuration_latest_version")
if officejs_latest_version:
if officejs_latest_version.endswith('/'):
officejs_latest_version = officejs_latest_version[:-1]
context = context.restrictedTraverse(officejs_latest_version, None)
if context is None:
return None
# now `context` is the app web section and the logic is same as with a normal
# ERP5JS web site.
translation_gadget_url = context.getLayoutProperty(
"configuration_translation_gadget_url")
if not translation_gadget_url:
return None
translation_gadget = context.getDocumentValue(translation_gadget_url)
if not translation_gadget:
return None
# find the .js containing translation data
for successor in translation_gadget.getImplicitSuccessorValueList():
successor = successor.getObject()
if successor.getReference() and successor.getReference().endswith(
'translation_data.js'):
return successor
return None
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>WebSite_getTranslationDataWebScriptValue</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
from Products.ERP5Type.Message import translateString
portal = context.getPortalObject()
gadget_translation_data_js = context.WebSite_getTranslationDataWebScriptValue()
if gadget_translation_data_js is None:
return context.Base_redirect(
form_id,
keep_items=dict(
portal_status_message=translateString("No translation data script.")))
gadget_translation_data_js.setTextContent(
context.WebSite_getTranslationDataTextContent())
portal.portal_workflow.doActionFor(
gadget_translation_data_js,
'edit_action',
comment=translateString(
"Translation data updated from web site ${web_site_id}.",
mapping={'web_site_id': context.getId()}))
# Edit web section modification date
portal.portal_workflow.doActionFor(
context,
'edit_action',
comment=translateString("Translation data updated.",))
if REQUEST is not None:
return context.Base_redirect(
form_id,
keep_items=dict(
portal_status_message=translateString("Translation data updated.")))
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>form_id=\'\', REQUEST=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>WebSite_updateTranslationData</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -14,7 +14,11 @@ ...@@ -14,7 +14,11 @@
</item> </item>
<item> <item>
<key> <string>action</string> </key> <key> <string>action</string> </key>
<value> <string>Base_createTranslateData</string> </value> <value> <string>WebSite_updateTranslationData</string> </value>
</item>
<item>
<key> <string>action_title</string> </key>
<value> <string></string> </value>
</item> </item>
<item> <item>
<key> <string>description</string> </key> <key> <string>description</string> </key>
...@@ -72,7 +76,7 @@ ...@@ -72,7 +76,7 @@
<key> <string>left</string> </key> <key> <string>left</string> </key>
<value> <value>
<list> <list>
<string>your_translation_data_file</string> <string>your_translation_data_reference</string>
</list> </list>
</value> </value>
</item> </item>
...@@ -87,7 +91,7 @@ ...@@ -87,7 +91,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>WebSite_createTranslationData</string> </value> <value> <string>WebSite_viewUpdateTranslationDataDialog</string> </value>
</item> </item>
<item> <item>
<key> <string>method</string> </key> <key> <string>method</string> </key>
...@@ -95,7 +99,7 @@ ...@@ -95,7 +99,7 @@
</item> </item>
<item> <item>
<key> <string>name</string> </key> <key> <string>name</string> </key>
<value> <string>WebSite_createTranslationData</string> </value> <value> <string>WebSite_viewUpdateTranslationDataDialog</string> </value>
</item> </item>
<item> <item>
<key> <string>pt</string> </key> <key> <string>pt</string> </key>
...@@ -111,7 +115,7 @@ ...@@ -111,7 +115,7 @@
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
<value> <string>Create Translation Data</string> </value> <value> <string>Update Translation Data</string> </value>
</item> </item>
<item> <item>
<key> <string>unicode_mode</string> </key> <key> <string>unicode_mode</string> </key>
......
...@@ -86,6 +86,6 @@ for tmp in param_dict: ...@@ -86,6 +86,6 @@ for tmp in param_dict:
context.Base_addUITestTranslation(message = tmp['message'], translation = tmp['translation'], language = tmp['language']) context.Base_addUITestTranslation(message = tmp['message'], translation = tmp['translation'], language = tmp['language'])
context.web_site_module.renderjs_runner.setAvailableLanguageSet(['en', 'fr', 'wo']) context.web_site_module.renderjs_runner.setAvailableLanguageSet(['en', 'fr', 'wo'])
context.web_site_module.renderjs_runner.Base_createTranslateData(translation_data_file='gadget_translation_data.js',batch_mode=1) context.web_site_module.renderjs_runner.WebSite_updateTranslationData()
context.ERP5Site_updateTranslationTable() context.ERP5Site_updateTranslationTable()
return 'done' return 'done'
...@@ -119,3 +119,63 @@ class TestRenderJSUpgrade(ERP5TypeTestCase): ...@@ -119,3 +119,63 @@ class TestRenderJSUpgrade(ERP5TypeTestCase):
[ [
'Error: Web Site %s references a non existant appcache %s' % (self.web_site.getRelativeUrl(), non_existant_appcache) 'Error: Web Site %s references a non existant appcache %s' % (self.web_site.getRelativeUrl(), non_existant_appcache)
], [str(m.getMessage()) for m in self.web_site.checkConsistency()]) ], [str(m.getMessage()) for m in self.web_site.checkConsistency()])
def test_upgrade_site_translation(self):
test_upgrade_site_translation_data_js = self.portal.web_page_module.newContent(
portal_type='Web Script',
reference='test_upgrade_site_translation_data.js',
text_content='// will be filled',
)
test_upgrade_site_translation_data_js.publish()
test_upgrade_site_translation_data_js_modification_date = test_upgrade_site_translation_data_js.getModificationDate()
test_upgrade_site_translation_data_html = self.portal.web_page_module.newContent(
portal_type='Web Page',
reference='test_upgrade_site_translation.html',
content_type='text/html',
text_content=textwrap.dedent('''
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>Translation Gadget</title>
<link rel="http://www.renderjs.org/rel/interface" href="interface_translation.html">
<!-- renderjs -->
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<!-- custom script -->
<script src="test_upgrade_site_translation_data.js" type="text/javascript"></script>
<script src="gadget_translation.js" type="text/javascript"></script>
</head>
<body>
</body>
</html>
'''),
)
test_upgrade_site_translation_data_html.publish()
self.web_site.setProperty(
'configuration_translation_gadget_url',
'test_upgrade_site_translation.html',
)
self.web_site.setAvailableLanguageList(['en', 'fa'])
self.tic()
self.assertEqual(
['Translation data script content is not up to date'],
[str(m.getMessage()) for m in self.web_site.checkConsistency()])
self.web_site.fixConsistency()
self.tic()
self.assertEqual(
[],
[str(m.getMessage()) for m in self.web_site.checkConsistency()])
self.assertIn(
"window.translation_data = ",
test_upgrade_site_translation_data_js.getTextContent())
self.assertGreater(
test_upgrade_site_translation_data_js.getModificationDate(),
test_upgrade_site_translation_data_js_modification_date)
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