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>
---
ui/js/src/kimchi.api.js | 18 ++++++++++++++++++
ui/js/src/kimchi.main.js | 12 +++++++++---
2 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/ui/js/src/kimchi.api.js b/ui/js/src/kimchi.api.js
index 7d85fdf..c20db2f 100644
--- a/ui/js/src/kimchi.api.js
+++ b/ui/js/src/kimchi.api.js
@@ -63,6 +63,24 @@ 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,
+ contentType : 'text/html', // 'application/json',
+ dataType : 'text', //'json', take the JSON directly rather
than parsing after updating the CherryPy config.
+ 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..1b5aa62 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=jQuery.parseJSON(i18nStrings); //take the JSON directly rather than
parsing after updating the CherryPy config.
+ buildTabs(initUI);
+ },
+ function(data){ //error
+ kimchi.message.error(data.responseJSON.reason);
+ buildTabs(initUI);
+ });
};
kimchi.getHelp = function(e) {
--
1.9.0