[Kimchi-devel] [PATCH] Issue #342: load i18n.html of the plugin
Hongliang Wang
hlwang at linux.vnet.ibm.com
Thu May 15 08:36:31 UTC 2014
On 05/14/2014 08:19 PM, shaohef at linux.vnet.ibm.com wrote:
> From: ShaoHe Feng <shaohef at 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 at 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,
The value will always be *true*.
The expression means:
if async is true, then
return true;
else
return 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) {
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ovirt.org/pipermail/kimchi-devel/attachments/20140515/148bf1c5/attachment.html>
More information about the Kimchi-devel
mailing list