From: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
Create an API for fetching the i18n JSON.
Use the API to load the kimchi UI strings.
API will need to be simplified after convincing CherryPy to respond to the reque
st for JSON.
Signed-off-by: Adam King <rak(a)linux.vnet.ibm.com>
Signed-off-by: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
---
ui/js/src/kimchi.api.js | 17 +++++++++++++++++
ui/js/src/kimchi.main.js | 12 +++++++++---
2 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/ui/js/src/kimchi.api.js b/ui/js/src/kimchi.api.js
index 7d85fdf..b2122a4 100644
--- a/ui/js/src/kimchi.api.js
+++ b/ui/js/src/kimchi.api.js
@@ -63,6 +63,23 @@ var kimchi = {
},
/**
+ * Get the i18 strings.
+ */
+ getI18n: function(suc, err, plugin) {
+ if (plugin==undefined) {
+ plugin="";
+ }
+ kimchi.requestJSON({
+ url : kimchi.url + plugin + '/i18n.json',
+ type : 'GET',
+ resend: true,
+ dataType : 'json',
+ success : suc,
+ error: err
+ });
+ },
+
+ /**
* Get the host static information.
*/
getHost: function(suc, err) {
diff --git a/ui/js/src/kimchi.main.js b/ui/js/src/kimchi.main.js
index 86fed5b..70840c1 100644
--- a/ui/js/src/kimchi.main.js
+++ b/ui/js/src/kimchi.main.js
@@ -247,9 +247,15 @@ kimchi.main = function() {
};
// Load i18n translation strings first and then render the page.
- $('#main').load('i18n.html', function() {
- buildTabs(initUI);
- });
+ kimchi.getI18n(
+ function(i18nStrings){ //success
+ i18n=i18nStrings; //take the JSON directly rather than parsing after updating
the CherryPy config.
+ buildTabs(initUI);
+ },
+ function(data){ //error
+ i18n={}
+ buildTabs(initUI);
+ });
};
kimchi.getHelp = function(e) {
--
1.9.0