Commit 485c3db0 authored by Jérome Perrin's avatar Jérome Perrin Committed by Gabriel Monnerat

HACK officejs_support_request_ui: translate form_view_discussable

This is done using the obsolete/slow translate/translateHtml because we
needed this for a customer project where we are not yet using the new
techniques for translation.

HACK because we'll do this with domsugar in erp5 master
parent f47c432c
<!DOCTYPE html>
<html>
<!--
@data-i18n="Posting comment"
@data-i18n="Post content can not be empty!"
@data-i18n="Comment added"
-->
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width" />
......@@ -21,13 +26,13 @@
<script id="template-document-list" type="text/x-handlebars-template">
{{#if comments }}
{{#each comments }}
<li>By <strong>{{ user }}</strong> -
<li><span data-i18n="By ">By </span><strong>{{ user }}</strong> -
<time datetime="{{ date }}" title="{{ date_formatted }}">{{ date_relative }}</time>
<br/>
{{{ text }}}
{{#if attachment_link }}
<br/>
<strong>Attachment: </strong>
<strong data-i18n="Attachment: ">Attachment: </strong>
<a href="{{attachment_link}}">{{ attachment_name }}</a>
{{/if}}
<hr id="post_item">
......@@ -49,9 +54,11 @@
</div>
<form>
<p style="background-color:#0E81C2;color:white;margin:1em 0;padding:0.5em">Comments:</p>
<ol id="post_list"></ol>
<h3 class="ui-content-title ui-body-c ui-icon ui-icon-custom ui-icon-random" id="comment-title" name="comment-title">&nbsp;Post a comment</h3>
<div data-i18n-translate-element="true">
<p style="background-color:#0E81C2;color:white;margin:1em 0;padding:0.5em" data-i18n="Comments:">Comments:</p>
<ol id="post_list"></ol>
<h3 class="ui-content-title ui-body-c ui-icon ui-icon-custom ui-icon-random" id="comment-title" name="comment-title" data-i18n=" Post a comment">&nbsp;Post a comment</h3>
</div>
<div data-gadget-url="gadget_editor.html"
data-gadget-scope="editor"
data-gadget-sandbox="">
......@@ -60,7 +67,9 @@
<div id="file_upload_div">
<input value="" name="attachment" id="attachment" type="file" title="Upload">
</div>
<input data-theme="b" data-inline="true" type="submit" data-i18n="[value]Post Comment" value="Post Comment" data-icon="check" disabled class="ui-disabled"/>
<div data-i18n-translate-element="true">
<input data-theme="b" data-inline="true" type="submit" data-i18n="[value]Post Comment" value="Post Comment" data-icon="check" disabled class="ui-disabled"/>
</div>
</form>
</div>
</body>
......
......@@ -256,7 +256,7 @@
</tuple>
<state>
<tuple>
<float>1554190620.27</float>
<float>1596786205.93</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -12,6 +12,8 @@
// Acquired methods
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("translate", "translate")
.declareAcquiredMethod("translateHtml", "translateHtml")
.declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("getSettingList", "getSettingList")
.declareAcquiredMethod("jio_getAttachment", "jio_getAttachment")
......@@ -37,7 +39,20 @@
.declareMethod('render', function (options) {
var gadget = this;
gadget.options = options;
return gadget.getSetting('hateoas_url')
return gadget.getElement()
.push(function (element) {
function translateElement(e) {
return gadget
.translateHtml(e.innerHTML)
.push(function (translatedHtml) {
e.innerHTML = translatedHtml;
});
}
return RSVP.all(Array.from(element.querySelectorAll('[data-i18n-translate-element]')).map(translateElement));
})
.push(function () {
return gadget.getSetting('hateoas_url')
})
.push(function (hateoas_url) {
gadget.hateoas_url = hateoas_url;
})
......@@ -173,7 +188,11 @@
})
.push(function (comment_list) {
var comments = gadget.element.querySelector("#post_list");
comments.innerHTML = comment_list_template({comments: comment_list});
return gadget
.translateHtml(comment_list_template({comments: comment_list}))
.push(function (translatedHtml) {
comments.innerHTML = translatedHtml;
})
});
})
.declareJob('submitPostComment', function () {
......@@ -187,7 +206,10 @@
})
.push(function (content) {
if (content.comment === '') {
return gadget.notifySubmitted({message: "Post content can not be empty!"});
return gadget.translate("Post content can not be empty!")
.push(function (translated_message) {
return gadget.notifySubmitted({message: translated_message});
})
}
submitButton = gadget.element.querySelector("input[type=submit]");
......@@ -198,7 +220,10 @@
submitButton.disabled = false;
submitButton.classList.remove("ui-disabled");
}
queue = gadget.notifySubmitted({message: "Posting comment"})
queue = gadget.translate("Posting comment").
push(function (message_posting_comment) {
return gadget.notifySubmitted({message: message_posting_comment})
})
.push(function () {
var choose_file_html_element = gadget.element.querySelector('#attachment'),
file_blob = choose_file_html_element.files[0],
......@@ -226,8 +251,12 @@
});
})
.push(function () {
return new RSVP.Queue().push(function () {
gadget.notifySubmitted({message: "Comment added", status: "success"});
return new RSVP.Queue().push(
function(){
return gadget.translate("Comment added")
}
).push(function (message_comment_added) {
gadget.notifySubmitted({message: message_comment_added, status: "success"});
}).push(function () {
return gadget.redirect({command: 'reload'});
});
......
......@@ -256,7 +256,7 @@
</tuple>
<state>
<tuple>
<float>1594840751.27</float>
<float>1596785336.88</float>
<string>UTC</string>
</tuple>
</state>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment