Commit 524e5445 authored by Xiaowu Zhang's avatar Xiaowu Zhang Committed by Xiaowu Zhang

erp5_web_renderjs_ui: available to translate

parent d1085bd6
...@@ -6,6 +6,7 @@ from ZODB.POSException import ConflictError ...@@ -6,6 +6,7 @@ from ZODB.POSException import ConflictError
import datetime import datetime
import time import time
from email.Utils import formatdate from email.Utils import formatdate
import re
if REQUEST is None: if REQUEST is None:
REQUEST = context.REQUEST REQUEST = context.REQUEST
...@@ -71,6 +72,7 @@ url_template_dict = { ...@@ -71,6 +72,7 @@ url_template_dict = {
} }
default_document_uri_template = url_template_dict["jio_get_template"] default_document_uri_template = url_template_dict["jio_get_template"]
Base_translateString = context.getPortalObject().Base_translateString
def getRealRelativeUrl(document): def getRealRelativeUrl(document):
return '/'.join(portal.portal_url.getRelativeContentPath(document)) return '/'.join(portal.portal_url.getRelativeContentPath(document))
...@@ -107,7 +109,7 @@ def renderField(traversed_document, field, form_relative_url, value=None, meta_t ...@@ -107,7 +109,7 @@ def renderField(traversed_document, field, form_relative_url, value=None, meta_t
"css_class": field.get_value("css_class"), "css_class": field.get_value("css_class"),
"hidden": field.get_value("hidden"), "hidden": field.get_value("hidden"),
"description": field.get_value("description"), "description": field.get_value("description"),
"title": field.get_value("title"), "title": Base_translateString(field.get_value("title")),
"required": field.get_value("required"), "required": field.get_value("required"),
# XXX Message can not be converted to json as is # XXX Message can not be converted to json as is
"items": field.get_value("items"), "items": field.get_value("items"),
...@@ -122,7 +124,7 @@ def renderField(traversed_document, field, form_relative_url, value=None, meta_t ...@@ -122,7 +124,7 @@ def renderField(traversed_document, field, form_relative_url, value=None, meta_t
"css_class": field.get_value("css_class"), "css_class": field.get_value("css_class"),
"hidden": field.get_value("hidden"), "hidden": field.get_value("hidden"),
"description": field.get_value("description"), "description": field.get_value("description"),
"title": field.get_value("title"), "title": Base_translateString(field.get_value("title")),
"required": field.get_value("required"), "required": field.get_value("required"),
"items": field.get_value("items"), "items": field.get_value("items"),
"select_first_item": field.get_value("first_item"), "select_first_item": field.get_value("first_item"),
...@@ -137,7 +139,7 @@ def renderField(traversed_document, field, form_relative_url, value=None, meta_t ...@@ -137,7 +139,7 @@ def renderField(traversed_document, field, form_relative_url, value=None, meta_t
"css_class": field.get_value("css_class"), "css_class": field.get_value("css_class"),
"hidden": field.get_value("hidden"), "hidden": field.get_value("hidden"),
"description": field.get_value("description"), "description": field.get_value("description"),
"title": field.get_value("title"), "title": Base_translateString(field.get_value("title")),
"required": field.get_value("required"), "required": field.get_value("required"),
# XXX Message can not be converted to json as is # XXX Message can not be converted to json as is
"items": field.get_value("items") "items": field.get_value("items")
...@@ -155,7 +157,7 @@ def renderField(traversed_document, field, form_relative_url, value=None, meta_t ...@@ -155,7 +157,7 @@ def renderField(traversed_document, field, form_relative_url, value=None, meta_t
"css_class": field.get_value("css_class"), "css_class": field.get_value("css_class"),
"hidden": field.get_value("hidden"), "hidden": field.get_value("hidden"),
"description": field.get_value("description"), "description": field.get_value("description"),
"title": field.get_value("title"), "title": Base_translateString(field.get_value("title")),
"required": field.get_value("required"), "required": field.get_value("required"),
} }
result["default"] = getFieldDefault(traversed_document, field, result["key"], value) result["default"] = getFieldDefault(traversed_document, field, result["key"], value)
...@@ -182,7 +184,7 @@ def renderField(traversed_document, field, form_relative_url, value=None, meta_t ...@@ -182,7 +184,7 @@ def renderField(traversed_document, field, form_relative_url, value=None, meta_t
"css_class": field.get_value("css_class"), "css_class": field.get_value("css_class"),
"hidden": field.get_value("hidden"), "hidden": field.get_value("hidden"),
"description": field.get_value("description"), "description": field.get_value("description"),
"title": field.get_value("title"), "title": Base_translateString(field.get_value("title")),
"required": field.get_value("required"), "required": field.get_value("required"),
"date_only": field.get_value("date_only"), "date_only": field.get_value("date_only"),
"ampm_time_style": field.get_value("ampm_time_style"), "ampm_time_style": field.get_value("ampm_time_style"),
...@@ -208,7 +210,7 @@ def renderField(traversed_document, field, form_relative_url, value=None, meta_t ...@@ -208,7 +210,7 @@ def renderField(traversed_document, field, form_relative_url, value=None, meta_t
jump_reference_list = [] jump_reference_list = []
if portal_type_list: if portal_type_list:
portal_type_list = [x[0] for x in portal_type_list] portal_type_list = [x[0] for x in portal_type_list]
translated_portal_type = [Base_translateString(x) for x in portal_type_list]
# ported from Base_jumpToRelatedDocument\n # ported from Base_jumpToRelatedDocument\n
base_category = field.get_value('base_category') base_category = field.get_value('base_category')
kw = {} kw = {}
...@@ -226,7 +228,7 @@ def renderField(traversed_document, field, form_relative_url, value=None, meta_t ...@@ -226,7 +228,7 @@ def renderField(traversed_document, field, form_relative_url, value=None, meta_t
{"portal_type": portal_type_list} {"portal_type": portal_type_list}
).asSearchTextExpression(sql_catalog)}) ).asSearchTextExpression(sql_catalog)})
} }
title = field.get_value("title"), title = field.get_value("title")
column_list = field.get_value("columns") column_list = field.get_value("columns")
proxy_listbox_ids = field.get_value("proxy_listbox_ids") proxy_listbox_ids = field.get_value("proxy_listbox_ids")
...@@ -254,16 +256,19 @@ def renderField(traversed_document, field, form_relative_url, value=None, meta_t ...@@ -254,16 +256,19 @@ def renderField(traversed_document, field, form_relative_url, value=None, meta_t
} }
result.pop("list_method_template", None) result.pop("list_method_template", None)
result["list_method"] = "portal_catalog" result["list_method"] = "portal_catalog"
result["title"] = title result["title"] = Base_translateString(title)
#set default listbox's column list to relation's column list #set default listbox's column list to relation's column list
if tmp[0] == 'Base_viewRelatedObjectListBase' and len(column_list) > 0: if tmp[0] == 'Base_viewRelatedObjectListBase' and len(column_list) > 0:
result["column_list"] = column_list result["column_list"] = []
listbox[grain[1]] = result for tmp_column in column_list:
result["column_list"].append((tmp_column[0], Base_translateString(tmp_column[1])))
listbox[Base_translateString(grain[1])] = result
break break
result = { result = {
"url": relative_url, "url": relative_url,
"translated_portal_types": translated_portal_type,
"portal_types": portal_type_list, "portal_types": portal_type_list,
"query": query, "query": query,
"catalog_index": field.get_value('catalog_index'), "catalog_index": field.get_value('catalog_index'),
...@@ -275,7 +280,7 @@ def renderField(traversed_document, field, form_relative_url, value=None, meta_t ...@@ -275,7 +280,7 @@ def renderField(traversed_document, field, form_relative_url, value=None, meta_t
"css_class": field.get_value("css_class"), "css_class": field.get_value("css_class"),
"hidden": field.get_value("hidden"), "hidden": field.get_value("hidden"),
"description": field.get_value("description"), "description": field.get_value("description"),
"title": title, "title": Base_translateString(title),
"required": field.get_value("required"), "required": field.get_value("required"),
"proxy_listbox_ids_len": len(proxy_listbox_ids), "proxy_listbox_ids_len": len(proxy_listbox_ids),
"listbox": listbox "listbox": listbox
...@@ -305,7 +310,7 @@ def renderField(traversed_document, field, form_relative_url, value=None, meta_t ...@@ -305,7 +310,7 @@ def renderField(traversed_document, field, form_relative_url, value=None, meta_t
"css_class": field.get_value("css_class"), "css_class": field.get_value("css_class"),
"hidden": field.get_value("hidden"), "hidden": field.get_value("hidden"),
"description": field.get_value("description"), "description": field.get_value("description"),
"title": field.get_value("title") "title": Base_translateString(field.get_value("title")),
} }
result["default"] = getFieldDefault(traversed_document, field, result["key"], value) result["default"] = getFieldDefault(traversed_document, field, result["key"], value)
elif meta_type == "MultiCheckBoxField": elif meta_type == "MultiCheckBoxField":
...@@ -316,7 +321,7 @@ def renderField(traversed_document, field, form_relative_url, value=None, meta_t ...@@ -316,7 +321,7 @@ def renderField(traversed_document, field, form_relative_url, value=None, meta_t
"css_class": field.get_value("css_class"), "css_class": field.get_value("css_class"),
"hidden": field.get_value("hidden"), "hidden": field.get_value("hidden"),
"description": field.get_value("description"), "description": field.get_value("description"),
"title": field.get_value("title"), "title": Base_translateString(field.get_value("title")),
"required": field.get_value("required"), "required": field.get_value("required"),
# XXX Message can not be converted to json as is # XXX Message can not be converted to json as is
"items": field.get_value("items"), "items": field.get_value("items"),
...@@ -330,18 +335,29 @@ def renderField(traversed_document, field, form_relative_url, value=None, meta_t ...@@ -330,18 +335,29 @@ def renderField(traversed_document, field, form_relative_url, value=None, meta_t
"css_class": field.get_value("css_class"), "css_class": field.get_value("css_class"),
"hidden": field.get_value("hidden"), "hidden": field.get_value("hidden"),
"description": field.get_value("description"), "description": field.get_value("description"),
"title": field.get_value("title"), "title": Base_translateString(field.get_value("title")),
"url": field.get_value("gadget_url"), "url": field.get_value("gadget_url"),
"sandbox": field.get_value("js_sandbox"), "sandbox": field.get_value("js_sandbox"),
} }
result["default"] = getFieldDefault(traversed_document, field, result["key"], value) result["default"] = getFieldDefault(traversed_document, field, result["key"], value)
elif meta_type == "ListBox": elif meta_type == "ListBox":
# XXX Not implemented # XXX Not implemented
column_list = field.get_value("columns") column_list = []
editable_column_list = field.get_value('editable_columns') for tmp in field.get_value("columns"):
column_list.append((tmp[0], Base_translateString(tmp[1])))
editable_column_list = []
for tmp in field.get_value('editable_columns'):
editable_column_list.append((tmp[0], Base_translateString(tmp[1])))
sort_column_list_tmp = []
for tmp in field.get_value('sort_columns'):
sort_column_list_tmp.append((tmp[0], Base_translateString(tmp[1])))
search_column_list_tmp = []
for tmp in field.get_value('search_columns'):
search_column_list_tmp.append((tmp[0], Base_translateString(tmp[1])))
sort_column_list_tmp = field.get_value('sort_columns')
search_column_list_tmp = field.get_value('search_columns')
sort_column_list = [] sort_column_list = []
search_column_list = [] search_column_list = []
...@@ -435,7 +451,7 @@ def renderField(traversed_document, field, form_relative_url, value=None, meta_t ...@@ -435,7 +451,7 @@ def renderField(traversed_document, field, form_relative_url, value=None, meta_t
"editable_column_list": editable_column_list, "editable_column_list": editable_column_list,
"show_anchor": field.get_value("anchor"), "show_anchor": field.get_value("anchor"),
# "line_list": line_list, # "line_list": line_list,
"title": field.get_value("title"), "title": Base_translateString(field.get_value("title")),
"key": key, "key": key,
"portal_type": portal_types, "portal_type": portal_types,
"lines": lines, "lines": lines,
...@@ -455,7 +471,7 @@ def renderField(traversed_document, field, form_relative_url, value=None, meta_t ...@@ -455,7 +471,7 @@ def renderField(traversed_document, field, form_relative_url, value=None, meta_t
result = { result = {
"type": meta_type, "type": meta_type,
"_debug": "Unsupported field type", "_debug": "Unsupported field type",
"title": field.get_value("title"), "title": Base_translateString(field.get_value("title")),
"key": key, "key": key,
} }
return result return result
...@@ -627,7 +643,7 @@ def renderFormDefinition(form, response_dict): ...@@ -627,7 +643,7 @@ def renderFormDefinition(form, response_dict):
group_list.append((group['gid'], field_list)) group_list.append((group['gid'], field_list))
response_dict["group_list"] = group_list response_dict["group_list"] = group_list
response_dict["title"] = form.getTitle() response_dict["title"] = Base_translateString(form.getTitle())
response_dict["pt"] = form.pt response_dict["pt"] = form.pt
response_dict["action"] = form.action response_dict["action"] = form.action
...@@ -743,7 +759,7 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None, ...@@ -743,7 +759,7 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None,
.getRelativeUrl(), .getRelativeUrl(),
"script_id": script.id "script_id": script.id
}, },
"name": traversed_document.getPortalType(), "name": Base_translateString(traversed_document.getPortalType())
} }
# Return info about container # Return info about container
...@@ -757,7 +773,7 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None, ...@@ -757,7 +773,7 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None,
"relative_url": container.getRelativeUrl(), "relative_url": container.getRelativeUrl(),
"script_id": script.id "script_id": script.id
}, },
"name": container.getTitle(), "name": Base_translateString(container.getTitle()),
} }
# XXX Loop on form rendering # XXX Loop on form rendering
...@@ -773,7 +789,7 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None, ...@@ -773,7 +789,7 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None,
erp5_action_list.append({ erp5_action_list.append({
'href': '%s' % view_action['url'], 'href': '%s' % view_action['url'],
'name': view_action['id'], 'name': view_action['id'],
'title': view_action['title'] 'title': Base_translateString(view_action['title'])
}) })
# Try to embed the form in the result # Try to embed the form in the result
if (view == view_action['id']): if (view == view_action['id']):
...@@ -1214,7 +1230,7 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None, ...@@ -1214,7 +1230,7 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None,
'href': url_template_dict["jio_search_template"] % { 'href': url_template_dict["jio_search_template"] % {
"query": make_query({"query": query}) "query": make_query({"query": query})
}, },
'name': action['name'], 'name': Base_translateString(re.sub(r' \(\d+\)$', '', action['name'])),
'count': action['count'], 'count': action['count'],
'module': default_document_uri_template % { 'module': default_document_uri_template % {
"relative_url": worklist_module_id "relative_url": worklist_module_id
......
...@@ -1076,12 +1076,130 @@ class TestERP5Document_getHateoas_mode_worklist(ERP5HALJSONStyleSkinsMixin): ...@@ -1076,12 +1076,130 @@ class TestERP5Document_getHateoas_mode_worklist(ERP5HALJSONStyleSkinsMixin):
result_dict = json.loads(result) result_dict = json.loads(result)
self.assertEqual(result_dict['_links']['self'], {"href": "http://example.org/bar"}) self.assertEqual(result_dict['_links']['self'], {"href": "http://example.org/bar"})
work_list = [x for x in result_dict['worklist'] if x['name'].startswith('Draft To Validate (')] work_list = [x for x in result_dict['worklist'] if x['name'].startswith('Draft To Validate')]
self.assertEqual(len(work_list), 1) self.assertEqual(len(work_list), 1)
self.assertTrue(work_list[0]['count'] > 0) self.assertTrue(work_list[0]['count'] > 0)
self.assertEqual(work_list[0]['name'], 'Draft To Validate (%i)' % work_list[0]['count']) self.assertEqual(work_list[0]['name'], 'Draft To Validate')
self.assertEqual(work_list[0]['module'], 'urn:jio:get:bar_module') self.assertEqual(work_list[0]['module'], 'urn:jio:get:bar_module')
self.assertEqual(work_list[0]['href'], 'urn:jio:allDocs?query=portal_type%3A%28%22Bar%22%20OR%20%22Foo%22%29%20AND%20simulation_state%3A%22draft%22') self.assertEqual(work_list[0]['href'], 'urn:jio:allDocs?query=portal_type%3A%28%22Bar%22%20OR%20%22Foo%22%29%20AND%20simulation_state%3A%22draft%22')
self.assertEqual(result_dict['_debug'], "worklist") self.assertEqual(result_dict['_debug'], "worklist")
class TestERP5Document_getHateoas_translation(ERP5HALJSONStyleSkinsMixin):
code_string = "\
from Products.CMFCore.utils import getToolByName\n\
translation_service = getToolByName(context, 'Localizer', None)\n\
if translation_service is not None :\n\
try:\n\
if not encoding:\n\
return translation_service.translate(catalog, msg, lang=lang, **kw)\n\
msg = translation_service.translate(catalog, msg, lang=lang, **kw)\n\
if same_type(msg, u''):\n\
msg = msg.encode(encoding)\n\
return msg\n\
except AttributeError:\n\
pass\n\
return msg"
@simulate('Base_getRequestUrl', '*args, **kwargs',
'return "http://example.org/bar"')
@simulate('Base_getRequestHeader', '*args, **kwargs',
'return "application/hal+json"')
@simulate('Base_translateString', 'msg, catalog="ui", encoding="utf8", lang="wo", **kw',
code_string)
@changeSkin('Hal')
def test_getHateoasBulk_default_view_translation(self):
self.portal.Base_createUITestLanguages()
param_dict = [
{ 'message': 'Title', 'translation': 'biaoti', 'language': 'wo'},
{ 'message': 'Draft To Validate', 'translation': 'daiyanzhen', 'language': 'wo'},
{ 'message': 'Foo', 'translation': 'Foo_zhongwen', 'language': 'wo'}]
for tmp in param_dict:
self.portal.Base_addUITestTranslation(message = tmp['message'], translation = tmp['translation'], language = tmp['language'])
document = self._makeDocument()
fake_request = do_fake_request("POST")
result = self.portal.web_site_module.hateoas.ERP5Document_getHateoas(
REQUEST=fake_request,
mode="bulk",
bulk_list=json.dumps([{"relative_url": document.getRelativeUrl(), "view": "view"}])
)
self.assertEquals(fake_request.RESPONSE.status, 200)
self.assertEquals(fake_request.RESPONSE.getHeader('Content-Type'),
"application/hal+json"
)
result_dict = json.loads(result)
self.assertEqual(result_dict['result_list'][0]['_embedded']['_view']['my_title']['title'], 'biaoti')
self.assertEqual(result_dict['result_list'][0]['_links']['type']['name'], 'Foo_zhongwen')
self.assertEqual(result_dict['result_list'][0]['_embedded']['_view']['listbox']['column_list'][1][1], 'biaoti')
@simulate('Base_getRequestUrl', '*args, **kwargs',
'return "http://example.org/bar"')
@simulate('Base_getRequestHeader', '*args, **kwargs',
'return "application/hal+json"')
@simulate('Base_translateString', 'msg, catalog="ui", encoding="utf8", lang="wo", **kw',
code_string)
@changeSkin('Hal')
def test_getHateoasDocument_result_translation(self):
document = self._makeDocument()
fake_request = do_fake_request("GET")
result = document.ERP5Document_getHateoas(REQUEST=fake_request)
self.assertEquals(fake_request.RESPONSE.status, 200)
self.assertEquals(fake_request.RESPONSE.getHeader('Content-Type'),
"application/hal+json"
)
result_dict = json.loads(result)
self.assertEqual(result_dict['_links']['type']['href'], 'urn:jio:get:portal_types/%s' % document.getPortalType())
self.assertEqual(result_dict['_links']['type']['name'], 'Foo_zhongwen')
self.assertEqual(result_dict['title'].encode("UTF-8"), document.getTitle())
self.assertEqual(result_dict['_debug'], "root")
@simulate('Base_getRequestUrl', '*args, **kwargs',
'return "http://example.org/bar"')
@simulate('Base_getRequestHeader', '*args, **kwargs',
'return "application/hal+json"')
@simulate('Base_translateString', 'msg, catalog="ui", encoding="utf8", lang="wo", **kw',
code_string)
@changeSkin('Hal')
def test_getHateoasWorklist_default_view_translation(self):
# self._makeDocument()
fake_request = do_fake_request("GET")
result = self.portal.web_site_module.hateoas.ERP5Document_getHateoas(
REQUEST=fake_request,
mode="worklist"
)
self.assertEquals(fake_request.RESPONSE.status, 200)
self.assertEquals(fake_request.RESPONSE.getHeader('Content-Type'),
"application/hal+json"
)
result_dict = json.loads(result)
self.assertEqual(result_dict['_links']['self'], {"href": "http://example.org/bar"})
work_list = [x for x in result_dict['worklist'] if x['name'].startswith('daiyanzhen')]
self.assertEqual(len(work_list), 1)
self.assertEqual(work_list[0]['name'], 'daiyanzhen')
self.assertTrue(work_list[0]['count'] > 0)
self.assertEqual(work_list[0]['module'], 'urn:jio:get:bar_module')
self.assertEqual(work_list[0]['href'], 'urn:jio:allDocs?query=portal_type%3A%28%22Bar%22%20OR%20%22Foo%22%29%20AND%20simulation_state%3A%22draft%22')
self.assertEqual(result_dict['_debug'], "worklist")
@simulate('Base_getRequestUrl', '*args, **kwargs',
'return "http://example.org/bar"')
@simulate('Base_getRequestHeader', '*args, **kwargs',
'return "application/hal+json"')
@simulate('Base_translateString', 'msg, catalog="ui", encoding="utf8", lang="wo", **kw',
code_string)
@changeSkin('Hal')
def test_getHateoasForm_no_view(self):
fake_request = do_fake_request("GET")
result = self.portal.web_site_module.hateoas.ERP5Document_getHateoas(REQUEST=fake_request, mode="traverse", relative_url="portal_skins/erp5_ui_test/Foo_view")
self.assertEquals(fake_request.RESPONSE.status, 200)
self.assertEquals(fake_request.RESPONSE.getHeader('Content-Type'),
"application/hal+json"
)
result_dict = json.loads(result)
self.assertEqual(result_dict['title'], 'Foo_zhongwen')
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_action</string>
</tuple>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_action</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>create_translation_data</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>View</string>
</tuple>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Action Information</string> </value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>1.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Create Translation Data</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/WebSite_createTranslationData</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -230,7 +230,6 @@ gadget_translation.html\n ...@@ -230,7 +230,6 @@ gadget_translation.html\n
gadget_translation.js\n gadget_translation.js\n
gadget_translation_data.js\n gadget_translation_data.js\n
handlebars.js\n handlebars.js\n
i18next.js\n
jiodev.js\n jiodev.js\n
renderjs.js\n renderjs.js\n
rsvp.js\n rsvp.js\n
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
.push(function () { .push(function () {
var title = erp5_document.title, var title = erp5_document.title,
portal_type = erp5_document._links.type.name; portal_type = erp5_document._links.type.name;
if (/ Module$/.test(portal_type)) { if (/ Module$/.test(erp5_document._links.type.href)) {
return portal_type; return portal_type;
} }
return portal_type + ': ' + title; return portal_type + ': ' + title;
......
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>950.28789.14822.18670</string> </value> <value> <string>954.14461.31508.53930</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -248,7 +248,7 @@ ...@@ -248,7 +248,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1460380170.56</float> <float>1476894652.41</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<!--
data-i18n=Front
data-i18n=Previous
data-i18n=Cancel
data-i18n=Back
data-i18n=Editable
data-i18n=Viewable
data-i18n=New
data-i18n=Save
data-i18n=Proceed
data-i18n=Add
data-i18n=Filter
data-i18n=Views
data-i18n=Jump
data-i18n=Delete
data-i18n=Export
data-i18n=Actions
data-i18n=Cut
data-i18n=Add
data-i18n=Previous
data-i18n=Next
data-i18n=Loading
-->
<meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no" /> <meta name="viewport" content="width=device-width, user-scalable=no" />
<title>ERP5 Header</title> <title>ERP5 Header</title>
......
...@@ -234,7 +234,7 @@ ...@@ -234,7 +234,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>955.10496.5559.9130</string> </value> <value> <string>954.5917.19875.40379</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -252,7 +252,7 @@ ...@@ -252,7 +252,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1479462688.84</float> <float>1474563958.55</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -15,6 +15,9 @@ ...@@ -15,6 +15,9 @@
<script data-renderjs-configuration="default_view_reference" type="text/x-renderjs-configuration">${default_view_reference}</script> <script data-renderjs-configuration="default_view_reference" type="text/x-renderjs-configuration">${default_view_reference}</script>
<script data-renderjs-configuration="hateoas_url" type="text/x-renderjs-configuration">${hateoas_url}</script> <script data-renderjs-configuration="hateoas_url" type="text/x-renderjs-configuration">${hateoas_url}</script>
<script data-renderjs-configuration="frontpage_gadget" type="text/x-renderjs-configuration">${frontpage_gadget}</script> <script data-renderjs-configuration="frontpage_gadget" type="text/x-renderjs-configuration">${frontpage_gadget}</script>
<script data-renderjs-configuration="language_map" type="text/x-renderjs-configuration">${language_map}</script>
<script data-renderjs-configuration="default_selected_language" type="text/x-renderjs-configuration">${default_selected_language}</script>
<script data-renderjs-configuration="website_url_set" type="text/x-renderjs-configuration">${website_url_set}</script>
<script src="rsvp.js"></script> <script src="rsvp.js"></script>
<script src="renderjs.js"></script> <script src="renderjs.js"></script>
......
...@@ -236,7 +236,7 @@ ...@@ -236,7 +236,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>955.19466.27249.10478</string> </value> <value> <string>954.5916.8255.62617</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -254,7 +254,7 @@ ...@@ -254,7 +254,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1479222440.45</float> <float>1475848425.64</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<!--
data-i18n=No records
data-i18n=Records
-->
<meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no" /> <meta name="viewport" content="width=device-width, user-scalable=no" />
<title>ERP5 Listbox</title> <title>ERP5 Listbox</title>
......
...@@ -234,7 +234,7 @@ ...@@ -234,7 +234,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>954.47421.47694.22459</string> </value> <value> <string>953.48474.52969.47820</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -252,7 +252,7 @@ ...@@ -252,7 +252,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1476967547.86</float> <float>1474554275.61</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -36,10 +36,11 @@ ...@@ -36,10 +36,11 @@
error_message_source = gadget_klass.__template_element error_message_source = gadget_klass.__template_element
.getElementById("error-message-template") .getElementById("error-message-template")
.innerHTML, .innerHTML,
error_message_template = Handlebars.compile(error_message_source); error_message_template = Handlebars.compile(error_message_source),
variable = {};
function renderListboxThead(gadget, template, head_value) { function renderListboxThead(gadget, template) {
return gadget.translateHtml(template({ return gadget.translateHtml(template({
head_value: gadget.props.head_value, head_value: gadget.props.head_value,
show_anchor: gadget.state.show_anchor, show_anchor: gadget.state.show_anchor,
...@@ -189,7 +190,8 @@ ...@@ -189,7 +190,8 @@
field_json = options.field_json, field_json = options.field_json,
i, i,
sort_column_list = [], sort_column_list = [],
search_column_list = []; search_column_list = [],
queue;
//only display which is in listbox's column list //only display which is in listbox's column list
if (field_json.sort_column_list.length) { if (field_json.sort_column_list.length) {
...@@ -215,7 +217,21 @@ ...@@ -215,7 +217,21 @@
} }
search_column_list.push(["searchable_text", "Searchable Text"]); search_column_list.push(["searchable_text", "Searchable Text"]);
return RSVP.Queue() queue = RSVP.Queue();
if (!variable.translated_records) {
queue
.push(function () {
return RSVP.all([
gadget.translate('Records'),
gadget.translate('No records')
]);
})
.push(function (results) {
variable.translated_records = results[0];
variable.translated_no_record = results[1];
});
}
queue
.push(function () { .push(function () {
// Cancel previous line rendering to not conflict with the asynchronous render for now // Cancel previous line rendering to not conflict with the asynchronous render for now
return gadget.renderContent(true); return gadget.renderContent(true);
...@@ -258,6 +274,7 @@ ...@@ -258,6 +274,7 @@
// Force line calculation in any case // Force line calculation in any case
return gadget.renderContent(); return gadget.renderContent();
}); });
return queue;
}) })
.onStateChange(function () { .onStateChange(function () {
...@@ -467,11 +484,11 @@ ...@@ -467,11 +484,11 @@
foot.next_classname = "ui-btn ui-icon-carat-r ui-btn-icon-right responsive ui-last-child"; foot.next_classname = "ui-btn ui-icon-carat-r ui-btn-icon-right responsive ui-last-child";
foot.next_url = url_list[1]; foot.next_url = url_list[1];
if ((begin_from === 0) && (counter === 0)) { if ((begin_from === 0) && (counter === 0)) {
foot.record = "No records"; foot.record = variable.translated_no_record;
} else if ((dataset.data.rows.length <= lines) && (begin_from === 0)) { } else if ((dataset.data.rows.length <= lines) && (begin_from === 0)) {
foot.record = counter + " Records"; foot.record = counter + " " + variable.translated_records;
} else { } else {
foot.record = "Records " + (((begin_from + lines) / lines - 1) * lines + 1) + " - " + (((begin_from + lines) / lines - 1) * lines + counter); foot.record = variable.translated_records + " " + (((begin_from + lines) / lines - 1) * lines + 1) + " - " + (((begin_from + lines) / lines - 1) * lines + counter);
} }
if (begin_from === 0) { if (begin_from === 0) {
......
...@@ -236,7 +236,7 @@ ...@@ -236,7 +236,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>954.47559.38051.59921</string> </value> <value> <string>955.20594.58985.30890</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -254,7 +254,7 @@ ...@@ -254,7 +254,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1476976330.15</float> <float>1479290108.34</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
url: gadget.state.url, url: gadget.state.url,
allow_creation: gadget.state.allow_creation, allow_creation: gadget.state.allow_creation,
portal_types: gadget.state.portal_types, portal_types: gadget.state.portal_types,
translated_portal_types: gadget.state.translated_portal_types,
value_relative_url: value_relative_url, value_relative_url: value_relative_url,
value_text: value_text, value_text: value_text,
value_uid: value_uid, value_uid: value_uid,
...@@ -55,6 +56,7 @@ ...@@ -55,6 +56,7 @@
url: field_json.url, url: field_json.url,
allow_creation: field_json.allow_creation, allow_creation: field_json.allow_creation,
portal_types: field_json.portal_types, portal_types: field_json.portal_types,
translated_portal_types: field_json.translated_portal_types,
relation_field_id: field_json.relation_field_id, relation_field_id: field_json.relation_field_id,
hidden: field_json.hidden hidden: field_json.hidden
}; };
......
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>955.7644.28099.443</string> </value> <value> <string>955.20651.19230.8738</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -248,7 +248,7 @@ ...@@ -248,7 +248,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1479375486.58</float> <float>1479293669.46</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
} }
return gadget.jio_allDocs({ return gadget.jio_allDocs({
query: Query.objectToSearchText(new ComplexQuery({operator: 'OR', query_list: query_list})), query: Query.objectToSearchText(new ComplexQuery({operator: 'OR', query_list: query_list})),
select_list: ["title", "portal_type"], select_list: ["title", "translated_portal_type"],
limit: id_list.length limit: id_list.length
}); });
}) })
...@@ -72,7 +72,7 @@ ...@@ -72,7 +72,7 @@
for (i = 0; i < result_list.length; i += 1) { for (i = 0; i < result_list.length; i += 1) {
document_dict[result_list[i][2]] = { document_dict[result_list[i][2]] = {
link: result_list[i][0], link: result_list[i][0],
title: (result_list[i][1].title || result_list[i][2]) + " (" + result_list[i][1].portal_type + ")" title: (result_list[i][1].title || result_list[i][2]) + " (" + result_list[i][1].translated_portal_type + ")"
}; };
} }
// Sort by access time // Sort by access time
......
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>954.45675.44850.53452</string> </value> <value> <string>953.52380.29788.47923</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -248,7 +248,7 @@ ...@@ -248,7 +248,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1476952911.66</float> <float>1473419443.85</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
.declareAcquiredMethod("getUrlFor", "getUrlFor") .declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("redirect", "redirect") .declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("jio_getAttachment", "jio_getAttachment") .declareAcquiredMethod("jio_getAttachment", "jio_getAttachment")
.declareAcquiredMethod("translateHtml", "translateHtml")
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// declared methods // declared methods
...@@ -120,6 +121,12 @@ ...@@ -120,6 +121,12 @@
]] ]]
} }
}); });
})
.push(function () {
return gadget.translateHtml(gadget.props.element.querySelector(".left").innerHTML);
})
.push(function (html) {
gadget.props.element.querySelector(".left").innerHTML = html;
}); });
}) })
.declareMethod("triggerSubmit", function () { .declareMethod("triggerSubmit", function () {
......
...@@ -234,7 +234,7 @@ ...@@ -234,7 +234,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>954.27036.35871.42001</string> </value> <value> <string>954.5791.20424.25736</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -252,7 +252,7 @@ ...@@ -252,7 +252,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1475744573.87</float> <float>1474556136.49</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<!--
data-i18n=Type
data-i18n=Reference
data-i18n=Description
data-i18n=State
-->
<head> <head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no" /> <meta name="viewport" content="width=device-width, user-scalable=no" />
......
...@@ -234,7 +234,7 @@ ...@@ -234,7 +234,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>950.28765.38539.13653</string> </value> <value> <string>953.56663.27739.23483</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -252,7 +252,7 @@ ...@@ -252,7 +252,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1460378755.69</float> <float>1474563707.59</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<!--
data-i18n=Worklist
-->
<head> <head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no" /> <meta name="viewport" content="width=device-width, user-scalable=no" />
......
...@@ -234,7 +234,7 @@ ...@@ -234,7 +234,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>954.45675.44850.53452</string> </value> <value> <string>953.56732.44606.43468</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -252,7 +252,7 @@ ...@@ -252,7 +252,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1476955713.49</float> <float>1474556302.46</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
view: 'view' view: 'view'
}}), }}),
// Remove the counter from the title // Remove the counter from the title
action_list[i].name.replace(/ \(\d+\)$/, ''), action_list[i].name,
action_list[i].count action_list[i].count
])); ]));
......
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>954.47218.14887.48486</string> </value> <value> <string>949.45349.17509.30190</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -248,7 +248,7 @@ ...@@ -248,7 +248,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1476956693.83</float> <float>1473173906.59</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
<li><a href="{{module_href}}" class="ui-btn ui-btn-icon-left ui-icon-puzzle-piece" data-i18n="Modules" accesskey="m">Modules</a></li> <li><a href="{{module_href}}" class="ui-btn ui-btn-icon-left ui-icon-puzzle-piece" data-i18n="Modules" accesskey="m">Modules</a></li>
<li><a href="{{worklist_href}}" class="ui-btn ui-btn-icon-left ui-icon-clipboard" data-i18n="Worklists" accesskey="w">Worklists</a></li> <li><a href="{{worklist_href}}" class="ui-btn ui-btn-icon-left ui-icon-clipboard" data-i18n="Worklists" accesskey="w">Worklists</a></li>
<li><a href="{{history_href}}" class="ui-btn ui-btn-icon-left ui-icon-history" data-i18n="History" accesskey="h">History</a></li> <li><a href="{{history_href}}" class="ui-btn ui-btn-icon-left ui-icon-history" data-i18n="History" accesskey="h">History</a></li>
<li><a href="{{search_href}}" class="ui-btn ui-btn-icon-left ui-icon-search" data-i18n="History" accesskey="s">Search</a></li> <li><a href="{{search_href}}" class="ui-btn ui-btn-icon-left ui-icon-search" data-i18n="Search" accesskey="s">Search</a></li>
<li><a href="{{preference_href}}" class="ui-btn ui-btn-icon-left ui-icon-gear" data-i18n="Preference">Preferences</a></li> <li><a href="{{preference_href}}" class="ui-btn ui-btn-icon-left ui-icon-gear" data-i18n="Preference">Preferences</a></li>
<!--div> <!--div>
{{#if language_list}} {{#if language_list}}
......
...@@ -234,7 +234,7 @@ ...@@ -234,7 +234,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>952.14137.61057.25617</string> </value> <value> <string>953.6580.58198.13568</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -252,7 +252,7 @@ ...@@ -252,7 +252,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1467279122.77</float> <float>1473162224.39</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -78,7 +78,7 @@ ...@@ -78,7 +78,7 @@
"search_href": all_result[4], "search_href": all_result[4],
"worklist_href": all_result[5] "worklist_href": all_result[5]
}); });
return tmp; return g.translateHtml(tmp);
}) })
.push(function (my_translated_or_plain_html) { .push(function (my_translated_or_plain_html) {
g.props.element.querySelector("div").innerHTML = my_translated_or_plain_html; g.props.element.querySelector("div").innerHTML = my_translated_or_plain_html;
......
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>952.1507.19232.15035</string> </value> <value> <string>953.6580.58198.13568</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -248,7 +248,7 @@ ...@@ -248,7 +248,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1466524414.0</float> <float>1473161369.59</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<!--
data-i18n=Workflow-Transitions
data-i18n=Actions
-->
<meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no" /> <meta name="viewport" content="width=device-width, user-scalable=no" />
<title>ERP5 Page Action</title> <title>ERP5 Page Action</title>
......
...@@ -234,7 +234,7 @@ ...@@ -234,7 +234,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>949.53789.19765.27784</string> </value> <value> <string>953.48219.30595.27340</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -252,7 +252,7 @@ ...@@ -252,7 +252,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1460378795.97</float> <float>1474556323.96</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<!--
data-i18n=Title
-->
<head> <head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no" /> <meta name="viewport" content="width=device-width, user-scalable=no" />
......
...@@ -234,7 +234,7 @@ ...@@ -234,7 +234,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>952.43255.60632.47035</string> </value> <value> <string>954.5909.42680.32921</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -252,7 +252,7 @@ ...@@ -252,7 +252,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1468942516.97</float> <float>1474563730.2</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -52,8 +52,7 @@ ...@@ -52,8 +52,7 @@
}) })
.push(function (form_gadget) { .push(function (form_gadget) {
var column_list = [ var column_list = [
['title', 'Title'] ['translated_title', 'Title']];
];
return form_gadget.render({ return form_gadget.render({
erp5_document: {"_embedded": {"_view": { erp5_document: {"_embedded": {"_view": {
"listbox": { "listbox": {
......
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>952.64761.25287.18397</string> </value> <value> <string>954.44756.57059.6894</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -248,7 +248,7 @@ ...@@ -248,7 +248,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1475244399.84</float> <float>1476893530.25</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<!--
data-i18n=User
data-i18n=Language
-->
<head> <head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no" /> <meta name="viewport" content="width=device-width, user-scalable=no" />
...@@ -12,10 +16,17 @@ ...@@ -12,10 +16,17 @@
<!-- custom script --> <!-- custom script -->
<script src="gadget_erp5_page_preference.js" type="text/javascript"></script> <script src="gadget_erp5_page_preference.js" type="text/javascript"></script>
</head>
<body>
Who are you?
</head>
<body>
<form class="preference">
<button type="submit" class="ui-btn ui-btn-b ui-btn-inline
ui-icon-edit ui-btn-icon-right ui-screen-hidden"></button>
<div data-gadget-url="gadget_erp5_form.html"
data-gadget-scope="erp5_form"
data-gadget-sandbox="public">
</div>
</form>
</body> </body>
</html> </html>
\ No newline at end of file
...@@ -234,7 +234,7 @@ ...@@ -234,7 +234,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>954.45675.44850.53452</string> </value> <value> <string>953.6663.63367.11298</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -252,7 +252,7 @@ ...@@ -252,7 +252,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1476958219.29</float> <float>1473246353.73</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
/*global window, rJS */ /*global window, rJS, RSVP */
/*jslint indent: 2, maxerr: 3 */ /*jslint indent: 2, maxerr: 3 */
(function (window, rJS) { (function (window, rJS, RSVP) {
"use strict"; "use strict";
rJS(window) rJS(window)
...@@ -8,22 +8,30 @@ ...@@ -8,22 +8,30 @@
// handle acquisition // handle acquisition
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
.declareAcquiredMethod("updateHeader", "updateHeader") .declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("translateHtml", "translateHtml") .declareAcquiredMethod("translate", "translate")
.declareAcquiredMethod("getSetting", "getSetting") .declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("setSetting", "setSetting")
.declareAcquiredMethod("jio_get", "jio_get") .declareAcquiredMethod("jio_get", "jio_get")
.declareAcquiredMethod("jio_allDocs", "jio_allDocs") .declareAcquiredMethod("jio_allDocs", "jio_allDocs")
.declareAcquiredMethod("notifySubmitting", "notifySubmitting")
.declareAcquiredMethod("notifySubmitted", "notifySubmitted")
.declareAcquiredMethod("redirect", "redirect")
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// declared methods // declared methods
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
.declareMethod("render", function () { .declareMethod("render", function () {
var gadget = this; var gadget = this,
user = "Who are you?";
// XXX: Lot of DOM touches
return gadget.updateHeader({ return gadget.updateHeader({
page_title: 'Preference' page_title: 'Preference',
save_action: true
}) })
.push(function () { .push(function () {
return gadget.getDeclaredGadget("erp5_form");
})
.push(function (erp5_form) {
gadget.state.erp5_form = erp5_form;
return gadget.getSetting('me'); return gadget.getSetting('me');
}) })
.push(function (me) { .push(function (me) {
...@@ -33,17 +41,89 @@ ...@@ -33,17 +41,89 @@
select_list: ['title'] select_list: ['title']
}) })
.push(function (result) { .push(function (result) {
gadget.element.textContent = result.data.rows[0].value.title; user = result.data.rows[0].value.title;
}); });
} }
// gadget.props.element.textContent = me;
}) })
.push(function () { .push(function () {
return gadget.translateHtml(gadget.element.innerHTML); return RSVP.all([
gadget.getSetting("language_map"),
gadget.getSetting("selected_language"),
gadget.getSetting("default_selected_language"),
gadget.translate("User"),
gadget.translate("Language")
]);
}) })
.push(function (my_translated_html) { .push(function (results) {
gadget.element.innerHTML = my_translated_html; var selected_language = results[1] || results[2],
key,
list_item = [],
options = JSON.parse(results[0]);
gadget.state.old_selected_lang = selected_language;
for (key in options) {
if (options.hasOwnProperty(key)) {
list_item.push([options[key], key]);
}
}
return gadget.state.erp5_form.render({
erp5_document: {"_embedded": {"_view": {
'User': {
"default": user,
"editable": 0,
"key": "field_user",
"title": results[3],
"type": "StringField"
},
'Language': {
"default": selected_language,
"editable": 1,
"items": list_item,
"key": "field_language",
"title": results[4],
"type": "ListField"
}
}},
"_links": {
"type": {
// form_list display portal_type in header
name: ""
}
}
},
form_definition: {
group_list: [[
"left",
[["User"], ["Language"]]
]]
}
});
});
})
.declareMethod('triggerSubmit', function () {
this.element.querySelector('button').click();
})
.onEvent('submit', function () {
var gadget = this,
selected_lang;
return gadget.notifySubmitting()
.push(function () {
return gadget.state.erp5_form.getContent();
})
.push(function (data) {
selected_lang = data.field_language;
return gadget.setSetting("selected_language", selected_lang);
})
.push(function () {
if (gadget.state.old_selected_lang !== selected_lang) {
return gadget.redirect({
command: 'change_language',
options: {
language: selected_lang
}
});
}
return gadget.notifySubmitted();
}); });
}); });
}(window, rJS)); }(window, rJS, RSVP));
\ No newline at end of file
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>954.47266.11723.40516</string> </value> <value> <string>955.20539.55071.38980</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -248,7 +248,7 @@ ...@@ -248,7 +248,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1476958263.79</float> <float>1479302491.62</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<!--
data-i18n=Jumps
data-i18n=Breadcrumb
-->
<head> <head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no" /> <meta name="viewport" content="width=device-width, user-scalable=no" />
......
...@@ -234,7 +234,7 @@ ...@@ -234,7 +234,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>946.44927.40202.16725</string> </value> <value> <string>953.49748.33034.5700</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -252,7 +252,7 @@ ...@@ -252,7 +252,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1460379644.0</float> <float>1474563753.89</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -34,15 +34,17 @@ ...@@ -34,15 +34,17 @@
<li class="ui-li-static ui-body-inherit ui-icon-mail-forward ui-btn-icon-right" data-relative-url="{{id}}" data-uid="{{uid}}">{{value}}</li> <li class="ui-li-static ui-body-inherit ui-icon-mail-forward ui-btn-icon-right" data-relative-url="{{id}}" data-uid="{{uid}}">{{value}}</li>
{{/each}} {{/each}}
{{#each type}} {{#each type}}
<li class="ui-li-static ui-body-inherit ui-bar-inherit ui-icon-plus ui-btn-icon-right" data-create-object="{{this}}" name="{{this}}">Create New {{this}}: {{../value}}</li> <li class="ui-li-static ui-body-inherit ui-bar-inherit ui-icon-plus ui-btn-icon-right" data-i18n="Create New" data-create-object="{{value}}" name="{{name}}">Create New
<span data-create-object="{{value}}"> {{name}}: {{../value}}</span></li>
{{/each}} {{/each}}
{{else}} {{else}}
<!--li class="ui-autocomplete ui-li ui-li-divider ui-bar-inherit ui-first-child" role="heading">No result</li--> <!--li class="ui-autocomplete ui-li ui-li-divider ui-bar-inherit ui-first-child" role="heading">No result</li-->
{{#each type}} {{#each type}}
<li class="ui-li-static ui-body-inherit ui-bar-inherit ui-icon-plus ui-btn-icon-right" data-create-object="{{this}}" name="{{this}}">Create New {{this}}: {{../value}}</li> <li class="ui-li-static ui-body-inherit ui-bar-inherit ui-icon-plus ui-btn-icon-right" data-i18n="Create New" data-create-object="{{value}}" name="{{name}}">Create New
<span data-create-object="{{value}}">{{name}}: {{../value}}</span></li>
{{/each}} {{/each}}
{{/if}} {{/if}}
<li class="ui-li-static ui-body-inherit ui-last-child ui-bar-inherit ui-icon-search ui-btn-icon-right" data-explore=true >Explore the Search Result List</li> <li class="ui-li-static ui-body-inherit ui-last-child ui-bar-inherit ui-icon-search ui-btn-icon-right" data-explore=true data-i18n="Explore the Search Result List" >Explore the Search Result List</li>
</script> </script>
</head> </head>
......
...@@ -234,7 +234,7 @@ ...@@ -234,7 +234,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>955.7622.39581.2525</string> </value> <value> <string>954.5712.44925.37444</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -252,7 +252,7 @@ ...@@ -252,7 +252,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1478511768.91</float> <float>1474553624.23</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -86,6 +86,7 @@ ...@@ -86,6 +86,7 @@
url: options.url, url: options.url,
allow_creation: options.allow_creation, allow_creation: options.allow_creation,
portal_types: options.portal_types, portal_types: options.portal_types,
translated_portal_types: options.translated_portal_types,
has_focus: false, has_focus: false,
relation_index: options.relation_index, relation_index: options.relation_index,
value_relative_url: options.value_relative_url, value_relative_url: options.value_relative_url,
...@@ -235,11 +236,14 @@ ...@@ -235,11 +236,14 @@
.push(function (result) { .push(function (result) {
var list = [], var list = [],
i, i,
type;
if (gadget.state.allow_creation) {
type = gadget.state.portal_types;
} else {
type = []; type = [];
if (gadget.state.allow_creation) {
for (i = 0; i < gadget.state.portal_types.length; i += 1) {
type.push({
name: gadget.state.translated_portal_types[i],
value: gadget.state.portal_types[i]
});
}
} }
for (i = 0; i < result.data.rows.length; i += 1) { for (i = 0; i < result.data.rows.length; i += 1) {
list.push({ list.push({
...@@ -249,11 +253,14 @@ ...@@ -249,11 +253,14 @@
}); });
} }
plane.className = JUMP_UNKNOWN_CLASS_STR; plane.className = JUMP_UNKNOWN_CLASS_STR;
ul.innerHTML = relation_listview_template({ return gadget.translateHtml(relation_listview_template({
list: list, list: list,
type: type, type: type,
value: value_text value: value_text
}); }));
})
.push(function (html) {
ul.innerHTML = html;
}); });
}); });
......
...@@ -236,7 +236,7 @@ ...@@ -236,7 +236,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>955.17976.26191.30156</string> </value> <value> <string>955.20665.33421.35549</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -254,7 +254,7 @@ ...@@ -254,7 +254,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1479133107.47</float> <float>1479294380.88</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
url: field_json.url, url: field_json.url,
allow_creation: field_json.allow_creation, allow_creation: field_json.allow_creation,
portal_types: field_json.portal_types, portal_types: field_json.portal_types,
translated_portal_types: field_json.translated_portal_types,
value_relative_url: field_json.relation_item_relative_url[0], value_relative_url: field_json.relation_item_relative_url[0],
relation_index: 0, relation_index: 0,
hidden: field_json.hidden hidden: field_json.hidden
......
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>955.7643.7350.21333</string> </value> <value> <string>955.18006.50413.2645</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -248,7 +248,7 @@ ...@@ -248,7 +248,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1479375314.48</float> <float>1479293469.27</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
COMMAND_SELECTION_NEXT = "selection_next", COMMAND_SELECTION_NEXT = "selection_next",
COMMAND_HISTORY_PREVIOUS = "history_previous", COMMAND_HISTORY_PREVIOUS = "history_previous",
COMMAND_PUSH_HISTORY = "push_history", COMMAND_PUSH_HISTORY = "push_history",
COMMAND_CHANGE_LANGUAGE = "change_language",
REDIRECT_TIMEOUT = 5055,
VALID_URL_COMMAND_DICT = {}; VALID_URL_COMMAND_DICT = {};
VALID_URL_COMMAND_DICT[COMMAND_DISPLAY_STATE] = null; VALID_URL_COMMAND_DICT[COMMAND_DISPLAY_STATE] = null;
VALID_URL_COMMAND_DICT[COMMAND_DISPLAY_STORED_STATE] = null; VALID_URL_COMMAND_DICT[COMMAND_DISPLAY_STORED_STATE] = null;
...@@ -40,6 +42,7 @@ ...@@ -40,6 +42,7 @@
VALID_URL_COMMAND_DICT[COMMAND_LOGIN] = null; VALID_URL_COMMAND_DICT[COMMAND_LOGIN] = null;
VALID_URL_COMMAND_DICT[COMMAND_RAW] = null; VALID_URL_COMMAND_DICT[COMMAND_RAW] = null;
VALID_URL_COMMAND_DICT[COMMAND_RELOAD] = null; VALID_URL_COMMAND_DICT[COMMAND_RELOAD] = null;
VALID_URL_COMMAND_DICT[COMMAND_CHANGE_LANGUAGE] = null;
function endsWith(str, suffix) { function endsWith(str, suffix) {
...@@ -108,6 +111,20 @@ ...@@ -108,6 +111,20 @@
if (command === COMMAND_RAW) { if (command === COMMAND_RAW) {
return options.url; return options.url;
} }
if (command === COMMAND_CHANGE_LANGUAGE) {
return new RSVP.Queue()
.push(function () {
return gadget.getSetting("website_url_set");
})
.push(function (result) {
var param_list = window.location.hash.split('#')[1],
new_url = JSON.parse(result)[options.language];
if (param_list) {
new_url += '#' + param_list;
}
return new_url;
});
}
var result = "#" + PREFIX_COMMAND + (command || ""), var result = "#" + PREFIX_COMMAND + (command || ""),
prefix = "?", prefix = "?",
key, key,
...@@ -858,7 +875,33 @@ ...@@ -858,7 +875,33 @@
}) })
.declareMethod('start', function () { .declareMethod('start', function () {
this.props.start_deferred.resolve(); var gadget = this;
return new RSVP.Queue()
.push(function () {
return RSVP.all([
gadget.getSetting("selected_language"),
gadget.getSetting("default_selected_language")
]);
})
.push(function (results) {
if (results[1] !== results[0] && results[0]) {
return gadget.redirect({
command: 'change_language',
options: {
language: results[0]
}
});
}
})
.push(function () {
gadget.props.start_deferred.resolve();
})
.push(undefined, function (error) {
if (error instanceof RSVP.CancellationError) {
return;
}
throw error;
});
}) })
.declareAcquiredMethod('renderApplication', 'renderApplication') .declareAcquiredMethod('renderApplication', 'renderApplication')
......
...@@ -232,7 +232,7 @@ ...@@ -232,7 +232,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>954.57620.63396.46779</string> </value> <value> <string>955.20572.17338.63419</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -250,7 +250,7 @@ ...@@ -250,7 +250,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1477580291.06</float> <float>1479288846.05</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<!--
data-i18n=All criterions (AND)
data-i18n=At least one (OR)
data-i18n=Exact Match
data-i18n=keyword
data-i18n=Contain
data-i18n=Equals To
data-i18n=Greater Than
data-i18n=Less Than
data-i18n=Not Greater Than
data-i18n=Not Less Than
data-i18n=Searchable Text
-->
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no" /> <meta name="viewport" content="width=device-width, user-scalable=no" />
...@@ -83,7 +96,7 @@ ...@@ -83,7 +96,7 @@
<fieldset class="ui-controlgroup ui-corner-all"> <fieldset class="ui-controlgroup ui-corner-all">
<select data-iconpos="left" name="heard_about"> <select data-iconpos="left" name="heard_about">
<option data-i18n="All criterions (AND)" value="AND">All criterions (AND)</option> <option data-i18n="All criterions (AND)" value="AND">All criterions (AND)</option>
<option data-i18n="At lease one (OR)" value="OR">At lease one (OR)</option> <option data-i18n="At least one (OR)" value="OR">At least one (OR)</option>
</select> </select>
</fieldset> </fieldset>
......
...@@ -234,7 +234,7 @@ ...@@ -234,7 +234,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>952.34496.35921.52275</string> </value> <value> <string>954.7210.40753.48042</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -252,7 +252,7 @@ ...@@ -252,7 +252,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1468414694.8</float> <float>1474905528.91</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
<script src="rsvp.js" type="text/javascript"></script> <script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script> <script src="renderjs.js" type="text/javascript"></script>
<script src="i18next.js"></script>
<!-- custom script --> <!-- custom script -->
<script src="gadget_translation_data.js" type="text/javascript"></script> <script src="gadget_translation_data.js" type="text/javascript"></script>
<script src="gadget_translation.js" type="text/javascript"></script> <script src="gadget_translation.js" type="text/javascript"></script>
......
...@@ -224,7 +224,7 @@ ...@@ -224,7 +224,7 @@
</item> </item>
<item> <item>
<key> <string>actor</string> </key> <key> <string>actor</string> </key>
<value> <string>romain</string> </value> <value> <string>zope</string> </value>
</item> </item>
<item> <item>
<key> <string>comment</string> </key> <key> <string>comment</string> </key>
...@@ -238,7 +238,7 @@ ...@@ -238,7 +238,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>945.43799.10287.64221</string> </value> <value> <string>949.45349.17509.30190</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -256,8 +256,8 @@ ...@@ -256,8 +256,8 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1445935119.77</float> <float>1467132987.54</float>
<string>GMT</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
</object> </object>
......
/*global document, window, rJS, translation_data */ /*global document, window, rJS, translation_data, RSVP */
/*jslint nomen: true, indent: 2 */ /*jslint nomen: true, indent: 2 */
(function (document, window, rJS, translation_data) { (function (document, window, rJS, translation_data, RSVP) {
"use strict"; "use strict";
function translate(string) { function translate(string, gadget) {
// XXX i18n.t return translation_data[gadget.state.language][string] || string;
return translation_data.en[string] || string;
} }
rJS(window)
/////////////////////////////////////////////////////////////////
// ready
/////////////////////////////////////////////////////////////////
.ready(function (gadget) {
gadget.property_dict = {};
})
.declareMethod('translate', function (string) {
// XXX Allow to change the language
return translate(string);
})
// translate a list of elements passed and returned as string // translate a list of elements passed and returned as string
.declareMethod('translateHtml', function (my_string) { function translateHtml(string, gadget) {
var temp, element_list, i, i_len, element, lookup, translate_list, target, var temp, element_list, i, i_len, element, lookup, translate_list, target,
route_text, has_breaks, l, l_len, gadget, j, j_len; route_text, has_breaks, l, l_len, j, j_len;
gadget = this;
// skip if no translations available
if (gadget.property_dict.translation_disabled) {
return my_string;
}
// NOTE: <div> cannot be used for everything... (like table rows) // NOTE: <div> cannot be used for everything... (like table rows)
// XXX: currently I only update where needed. Eventually all calls to // XXX: currently I only update where needed. Eventually all calls to
// translateHtml should pass "their" proper wrapping element // translateHtml should pass "their" proper wrapping element
temp = document.createElement("div"); temp = document.createElement("div");
temp.innerHTML = my_string; temp.innerHTML = string;
element_list = temp.querySelectorAll("[data-i18n]"); element_list = temp.querySelectorAll("[data-i18n]");
...@@ -56,7 +33,7 @@ ...@@ -56,7 +33,7 @@
case "[placeholder": case "[placeholder":
case "[alt": case "[alt":
case "[title": case "[title":
element.setAttribute(target[0].substr(1), translate(target[1])); element.setAttribute(target[0].substr(1), translate(target[1], gadget));
break; break;
case "[value": case "[value":
has_breaks = element.previousSibling.textContent.match(/\n/g); has_breaks = element.previousSibling.textContent.match(/\n/g);
...@@ -72,37 +49,37 @@ ...@@ -72,37 +49,37 @@
} }
} }
if (route_text && (has_breaks || []).length === 0) { if (route_text && (has_breaks || []).length === 0) {
element.previousSibling.textContent = translate(target[1]); element.previousSibling.textContent = translate(target[1], gadget);
} }
element.value = translate(target[1]); element.value = translate(target[1], gadget);
break; break;
case "[parent": case "[parent":
element.parentNode.childNodes[0].textContent = element.parentNode.childNodes[0].textContent =
translate(target[1]); translate(target[1], gadget);
break; break;
case "[node": case "[node":
element.childNodes[0].textContent = translate(target[1]); element.childNodes[0].textContent = translate(target[1], gadget);
break; break;
case "[last": case "[last":
// if null, append, if textnode replace, if span, appned // if null, append, if textnode replace, if span, appned
if (element.lastChild && element.lastChild.nodeType === 3) { if (element.lastChild && element.lastChild.nodeType === 3) {
element.lastChild.textContent = translate(target[1]); element.lastChild.textContent = translate(target[1], gadget);
} else { } else {
element.appendChild(document.createTextNode(translate(target[1]))); element.appendChild(document.createTextNode(translate(target[1], gadget)));
} }
break; break;
case "[html": case "[html":
element.innerHTML = translate(target[1]); element.innerHTML = translate(target[1], gadget);
break; break;
default: default:
if (element.hasChildNodes()) { if (element.hasChildNodes()) {
for (j = 0, j_len = element.childNodes.length; j < j_len; j += 1) { for (j = 0, j_len = element.childNodes.length; j < j_len; j += 1) {
if (element.childNodes[j].nodeType === 3) { if (element.childNodes[j].nodeType === 3) {
element.childNodes[j].textContent = translate(translate_list[l]); element.childNodes[j].textContent = translate(translate_list[l], gadget);
} }
} }
} else { } else {
element.textContent = translate(translate_list[l]); element.textContent = translate(translate_list[l], gadget);
} }
break; break;
} }
...@@ -111,6 +88,45 @@ ...@@ -111,6 +88,45 @@
} }
// return string // return string
return temp.innerHTML; return temp.innerHTML;
}
rJS(window)
.declareAcquiredMethod("getSetting", "getSetting")
.declareMethod('translate', function (string) {
// XXX Allow to change the language
var gadget = this;
if (!gadget.state.language) {
return new RSVP.Queue()
.push(function () {
return RSVP.all([
gadget.getSetting("selected_language"),
gadget.getSetting("default_selected_language")
]);
})
.push(function (results) {
gadget.state.language = results[0] || results[1];
return translate(string, gadget);
});
}
return translate(string, gadget);
})
.declareMethod('translateHtml', function (string) {
var gadget = this;
if (!gadget.state.language) {
return new RSVP.Queue()
.push(function () {
return RSVP.all([
gadget.getSetting("selected_language"),
gadget.getSetting("default_selected_language")
]);
})
.push(function (results) {
gadget.state.language = results[0] || results[1];
return translateHtml(string, gadget);
});
}
return translateHtml(string, gadget);
}); });
}(document, window, rJS, translation_data)); }(document, window, rJS, translation_data, RSVP));
...@@ -234,7 +234,7 @@ ...@@ -234,7 +234,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>948.17388.42239.34542</string> </value> <value> <string>955.18006.50413.2645</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -252,7 +252,7 @@ ...@@ -252,7 +252,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1452009218.06</float> <float>1479302155.8</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
This source diff could not be displayed because it is too large. You can view the blob instead.
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Web Script" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Change_local_roles_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>content_md5</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>i18next.js</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>rjs_plugin_i18next_js</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value> <string>en</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Web Script</string> </value>
</item>
<item>
<key> <string>short_title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>plugin i18next JS</string> </value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>1.7.4</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</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>
<item>
<key> <string>document_publication_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>edit_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>processing_status_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAU=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>publish_alive</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>super_sven</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1418835142.27</float>
<string>GMT</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>published_alive</string> </value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>edit</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>super_sven</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>939.44304.41368.21111</string> </value>
</item>
<item>
<key> <string>state</string> </key>
<value> <string>current</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1418834941.27</float>
<string>GMT</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>detect_converted_file</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>super_sven</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_processing_state</string> </key>
<value> <string>converted</string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>0.0.0.0</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1418834767.8</float>
<string>GMT</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
</ZopeData>
...@@ -397,7 +397,7 @@ ...@@ -397,7 +397,7 @@
</item> </item>
<item> <item>
<key> <string>static_language_selection</string> </key> <key> <string>static_language_selection</string> </key>
<value> <int>0</int> </value> <value> <int>1</int> </value>
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
......
import re
import json
Base_translateString = context.Base_translateString
#(data-i18n)=["']{{((?:.(?!["']?(?:\S+)=|[>"']))+.)}}["']
attribute_filter_re = re.compile(r"""(data-i18n)=["']?((?:.(?!["']?\s+(?:\S+)=|[>"']))+.)["']?""")
tmp_re = re.compile(r"""/[{}]/g, """"")
translate_word = []
web_page_list = context.Base_getListFileFromAppcache(only_html=1)
for web_page in web_page_list:
web_page = context.web_page_module.searchFolder(portal_type='Web Page',reference=web_page)[0]
data = attribute_filter_re.findall(web_page.getTextContent())
for attribute in data:
a = re.sub(r'[{|}]', "", attribute[1])
a = re.sub(r'\[.*?\]', "", a)
if a:
translate_word.append(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 = {}
for language in language_list:
tmp[language] = {}
for word in translate_word:
tmp[language][word] = Base_translateString(word, lang = language)
content += " window.translation_data = " + json.dumps(tmp, indent=3, ensure_ascii=False, separators=(',', ': '))
content += ";\n}(window));"
#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]
translation_data_file.edit(text_content = content)
if batch_mode:
return 'done'
return context.Base_redirect('view', keep_items=dict(portal_status_message=Base_translateString("Translation Data Create")))
<?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> translation_data_file, batch_mode=0</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_createTranslateData</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
appcache_file = context.getLayoutProperty("configuration_manifest_url", default="gadget_erp5.appcache")
text_content = context.web_page_module.searchFolder(
portal_type= 'Web Manifest',
reference = appcache_file)[0].getTextContent()
translation_data_file = []
file_list = []
for file in text_content.split('\n'):
file = file.split('/')[-1]
if file.endswith('.html'):
file_list.append(file)
continue
if file.endswith('.js') and not only_html:
if file.endswith('translation_data.js'):
translation_data_file = [file]
continue
file_list.append(file)
return translation_data_file + file_list
<?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>only_html = 0</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_getListFileFromAppcache</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ERP5 Form" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>action</string> </key>
<value> <string>Base_createTranslateData</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>edit_order</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>enctype</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>group_list</string> </key>
<value>
<list>
<string>left</string>
<string>right</string>
<string>center</string>
<string>bottom</string>
<string>hidden</string>
</list>
</value>
</item>
<item>
<key> <string>groups</string> </key>
<value>
<dictionary>
<item>
<key> <string>bottom</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>center</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>hidden</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>left</string> </key>
<value>
<list>
<string>your_translation_data_file</string>
</list>
</value>
</item>
<item>
<key> <string>right</string> </key>
<value>
<list/>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>WebSite_createTranslationData</string> </value>
</item>
<item>
<key> <string>method</string> </key>
<value> <string>POST</string> </value>
</item>
<item>
<key> <string>name</string> </key>
<value> <string>WebSite_createTranslationData</string> </value>
</item>
<item>
<key> <string>pt</string> </key>
<value> <string>form_dialog</string> </value>
</item>
<item>
<key> <string>row_length</string> </key>
<value> <int>4</int> </value>
</item>
<item>
<key> <string>stored_encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Create Translation Data</string> </value>
</item>
<item>
<key> <string>unicode_mode</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>update_action</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>update_action_title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ListField" module="Products.Formulator.StandardFields"/>
</pickle>
<pickle>
<dictionary>
<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>
<item>
<key> <string>required_not_found</string> </key>
<value> <string>Input is required but no input given.</string> </value>
</item>
<item>
<key> <string>unknown_selection</string> </key>
<value> <string>You selected an item that was not in the list.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra_item</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>first_item</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>items</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>required</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>unicode</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>whitespace_preserve</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra_item</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>first_item</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</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>required</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>unicode</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>whitespace_preserve</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra_item</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>first_item</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>items</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>required</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>5</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Translation Data File</string> </value>
</item>
<item>
<key> <string>unicode</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>whitespace_preserve</string> </key>
<value> <int>0</int> </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_getListFileFromAppcache()]</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
import json
import re
if REQUEST is None: if REQUEST is None:
REQUEST = context.REQUEST REQUEST = context.REQUEST
if response is None: if response is None:
...@@ -6,6 +9,22 @@ if response is None: ...@@ -6,6 +9,22 @@ if response is None:
default_web_page = context default_web_page = context
web_section = REQUEST.get("current_web_section") web_section = REQUEST.get("current_web_section")
available_language_set = web_section.getLayoutProperty("available_language_set", default=['en'])
portal = context.getPortalObject()
default_language = web_section.getLayoutProperty("default_available_language", default='en')
website_url_set = {}
#simplify code of Base_doLanguage, can't ues Base_doLanguage directly
root_website_url = web_section.getOriginalDocument().absolute_url()
website_url_pattern = r'^%s(?:%s)*(/|$)' % (
re.escape(root_website_url),
'|'.join('/' + re.escape(x) for x in available_language_set))
for language in available_language_set:
if language == default_language:
website_url_set[language] = re.sub(website_url_pattern, r'%s/\1' % root_website_url, web_section.absolute_url())
else:
website_url_set[language]= re.sub(website_url_pattern, r'%s/%s/\1' % (root_website_url, language), web_section.absolute_url())
return default_web_page.WebPage_viewAsWeb(mapping_dict={ return default_web_page.WebPage_viewAsWeb(mapping_dict={
"frontpage_gadget": web_section.getLayoutProperty("configuration_frontpage_gadget_url", default="worklist"), "frontpage_gadget": web_section.getLayoutProperty("configuration_frontpage_gadget_url", default="worklist"),
...@@ -18,5 +37,8 @@ return default_web_page.WebPage_viewAsWeb(mapping_dict={ ...@@ -18,5 +37,8 @@ return default_web_page.WebPage_viewAsWeb(mapping_dict={
"header_gadget": web_section.getLayoutProperty("configuration_header_gadget_url", default="gadget_erp5_header.html"), "header_gadget": web_section.getLayoutProperty("configuration_header_gadget_url", default="gadget_erp5_header.html"),
"jio_gadget": web_section.getLayoutProperty("configuration_jio_gadget_url", default="gadget_jio.html"), "jio_gadget": web_section.getLayoutProperty("configuration_jio_gadget_url", default="gadget_jio.html"),
"translation_gadget": web_section.getLayoutProperty("configuration_translation_gadget_url", default="gadget_translation.html"), "translation_gadget": web_section.getLayoutProperty("configuration_translation_gadget_url", default="gadget_translation.html"),
"manifest_url": web_section.getLayoutProperty("configuration_manifest_url", default="gadget_erp5.appcache") "manifest_url": web_section.getLayoutProperty("configuration_manifest_url", default="gadget_erp5.appcache"),
"language_map": json.dumps({tmp['id']: portal.Base_translateString(tmp['title'], lang = tmp['id']) for tmp in portal.Localizer.get_languages_map() if tmp['id'] in available_language_set}),
"default_selected_language": portal.Localizer.get_selected_language(),
"website_url_set": json.dumps(website_url_set),
}) })
...@@ -6,7 +6,8 @@ from ZTUtils import make_query ...@@ -6,7 +6,8 @@ from ZTUtils import make_query
portal = context.getPortalObject() portal = context.getPortalObject()
if (came_from is None): if (came_from is None):
came_from = context.getPermanentURL(context.getWebSiteValue()) #XXX Hardcoded for JS app's url end with '/'
came_from = "%s/" % context.getPermanentURL(context.getWebSiteValue())
portal.portal_skins.updateSkinCookie() portal.portal_skins.updateSkinCookie()
portal.setupCurrentSkin(REQUEST) portal.setupCurrentSkin(REQUEST)
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<div data-gadget-scope='header'> <div data-gadget-scope='header'>
<div class="ui-header"> <div class="ui-header">
<h1><span>Recover your account</span></h1> <h1><span i18n:domain="ui" i18n:translate="">Recover your account</span></h1>
</div> </div>
</div> </div>
...@@ -28,13 +28,13 @@ ...@@ -28,13 +28,13 @@
<section> <section>
<form method="post" tal:attributes="action python: context.absolute_url()"> <form method="post" tal:attributes="action python: context.absolute_url()">
<div class="ui-field-contain"> <div class="ui-field-contain">
<label data-i18n="Login">Login<span></span></label> <label i18n:domain="ui" i18n:translate="">Login</label>
<div><input autofocus type="text" name="user_login" value="" required=""></div> <div><input autofocus type="text" name="user_login" value="" required=""></div>
</div> </div>
<br/> <br/>
<div class="ui-field-contain"> <div class="ui-field-contain">
<label></label> <label></label>
<div><input type="submit" data-i18n="[value]Validate" value="Validate" tal:attributes="name python: '%s:method' % (form_action, )"/></div> <div><input type="submit" value="Validate" i18n:attributes="value" i18n:domain="ui" tal:attributes="name python: '%s:method' % (form_action, )"/></div>
</div> </div>
<input type="hidden" name="url" tal:attributes="value python: context.absolute_url()" /> <input type="hidden" name="url" tal:attributes="value python: context.absolute_url()" />
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<div data-gadget-scope='header'> <div data-gadget-scope='header'>
<div class="ui-header"> <div class="ui-header">
<h1><span>Connect</span></h1> <h1><span i18n:domain="ui" i18n:translate="">Connect</span></h1>
</div> </div>
</div> </div>
...@@ -34,22 +34,22 @@ ...@@ -34,22 +34,22 @@
<form method="post" tal:attributes="action python: '%s/' % context.absolute_url()"> <form method="post" tal:attributes="action python: '%s/' % context.absolute_url()">
<div class="ui-field-contain"> <div class="ui-field-contain">
<label data-i18n="Login">Login<span></span></label> <label i18n:domain="ui" i18n:translate="" >Login</label>
<div><input autofocus type="text" name="__ac_name" value="" required=""></div> <div><input autofocus type="text" name="__ac_name" value="" required=""></div>
</div> </div>
<div class="ui-field-contain"> <div class="ui-field-contain">
<label data-i18n="Password">Password<span></span></label> <label i18n:domain="ui" i18n:translate="" >Password</label>
<div><input type="password" name="__ac_password" value="" required=""></div> <div><input type="password" name="__ac_password" value="" required=""></div>
</div> </div>
<div class="ui-field-contain"> <div class="ui-field-contain">
<label></label> <label></label>
<div tal:define="absolute_url python:context.absolute_url()"> <div tal:define="absolute_url python:context.absolute_url()">
<a tal:attributes="href python: '%s/WebSite_viewRecoverAccount?came_from=%s' % (absolute_url, absolute_url)">I forgot my password!</a> <a i18n:domain="ui" i18n:translate="" tal:attributes="href python: '%s/WebSite_viewRecoverAccount?came_from=%s' % (absolute_url, absolute_url)">I forgot my password!</a>
</div> </div>
</div><br/> </div><br/>
<div class="ui-field-contain"> <div class="ui-field-contain">
<label></label> <label></label>
<div><input type="submit" value="Login" tal:attributes="name python: '%s:method' % (form_action, )"/></div> <div><input type="submit" value='Login' i18n:attributes="value" i18n:domain="ui" tal:attributes="name python: '%s:method' % (form_action, )"/></div>
</div> </div>
......
...@@ -7,6 +7,7 @@ Web Script | view ...@@ -7,6 +7,7 @@ Web Script | view
Web Script | view_editor Web Script | view_editor
Web Script | view_syntax Web Script | view_syntax
Web Script | web_view Web Script | web_view
Web Site | create_translation_data
Web Style | version_view Web Style | version_view
Web Style | view Web Style | view
Web Style | view_editor Web Style | view_editor
......
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