<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<br>
<div class="moz-cite-prefix">On 05/14/2014 08:19 PM,
<a class="moz-txt-link-abbreviated" href="mailto:shaohef@linux.vnet.ibm.com">shaohef@linux.vnet.ibm.com</a> wrote:<br>
</div>
<blockquote
cite="mid:1400069987-3020-1-git-send-email-shaohef@linux.vnet.ibm.com"
type="cite">
<pre wrap="">From: ShaoHe Feng <a class="moz-txt-link-rfc2396E" href="mailto:shaohef@linux.vnet.ibm.com"><shaohef@linux.vnet.ibm.com></a>
Apparently, in plugin code there is no way to insert new entries into
Kimchi ./ui/pages/i18n.html.tmpl, so every plugin should provide its own
i18n.html.tmpl.
each plugin provides a "plugins/plugin-name/ui/pages/i18n.html.tmpl",
and maps it to the URI "plugins/plugin-name/i18n.html". This is already
supported by the kimchi back-end. What we have to do is just to load
"plugins/plugin-name/i18n.html" in the front-end code.
Signed-off-by: ShaoHe Feng <a class="moz-txt-link-rfc2396E" href="mailto:shaohef@linux.vnet.ibm.com"><shaohef@linux.vnet.ibm.com></a>
---
ui/js/src/kimchi.api.js | 3 ++-
ui/js/src/kimchi.main.js | 19 ++++++++++++++++++-
2 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/ui/js/src/kimchi.api.js b/ui/js/src/kimchi.api.js
index 7d85fdf..d4d92d8 100644
--- a/ui/js/src/kimchi.api.js
+++ b/ui/js/src/kimchi.api.js
@@ -558,13 +558,14 @@ var kimchi = {
});
},
- listPlugins : function(suc, err) {
+ listPlugins : function(suc, err, async) {
kimchi.requestJSON({
url : kimchi.url + 'plugins',
type : 'GET',
contentType : 'application/json',
dataType : 'json',
resend: true,</pre>
</blockquote>
<br>
<blockquote
cite="mid:1400069987-3020-1-git-send-email-shaohef@linux.vnet.ibm.com"
type="cite">
<pre wrap="">
+ async: async ? async : true,</pre>
</blockquote>
The value will always be <b>true</b>.<br>
<br>
The expression means:<br>
<br>
if async is true, then<br>
return true;<br>
else<br>
return true.<br>
<blockquote
cite="mid:1400069987-3020-1-git-send-email-shaohef@linux.vnet.ibm.com"
type="cite">
<pre wrap="">
success : suc,
error : err
});
diff --git a/ui/js/src/kimchi.main.js b/ui/js/src/kimchi.main.js
index 86fed5b..82778cc 100644
--- a/ui/js/src/kimchi.main.js
+++ b/ui/js/src/kimchi.main.js
@@ -62,8 +62,19 @@ kimchi.main = function() {
return tabs;
};
+ var retrieveI18ns = function(url) {
+ $.ajax({
+ url : url,
+ async : false,
+ success : function(html) {
+ $('#main').append(html)},
+ error: function(html) {}
+ });
+ };
+
var tabConfigUrl = '/config/ui/tabs.xml';
var pluginConfigUrl = '/plugins/{plugin}/ui/config/tab-ext.xml';
+ var pluginI18nUrl = 'plugins/{plugin}/i18n.html';
var DEFAULT_HASH;
var buildTabs = function(callback) {
var tabs = retrieveTabs(tabConfigUrl);
@@ -72,6 +83,10 @@ kimchi.main = function() {
var url = kimchi.template(pluginConfigUrl, {
plugin: p
});
+ var i18nurl = kimchi.template(pluginI18nUrl, {
+ plugin: p
+ });
+ retrieveI18ns(i18nurl);
tabs.push.apply(tabs, retrieveTabs(url));
});
@@ -85,7 +100,9 @@ kimchi.main = function() {
$('#nav-menu').append(genTabs(tabs));
callback && callback();
- });
+ }, function(data) {
+ kimchi.message.error(data.responseJSON.reason);
+ }, true);
};
var onLanguageChanged = function(lang) {
</pre>
</blockquote>
<br>
</body>
</html>