From: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
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 <shaohef(a)linux.vnet.ibm.com>
---
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,
+ async: async ? async : true,
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) {
--
1.9.0
Show replies by date