[Kimchi-devel] [PATCH V5 4/7] Add JS API for fetching i18n JSON
Daniel H Barboza
danielhb at linux.vnet.ibm.com
Mon Jun 9 11:18:43 UTC 2014
Reviewed-by: Daniel Barboza <danielhb at linux.vnet.ibm.com>
On 06/09/2014 07:09 AM, shaohef at linux.vnet.ibm.com wrote:
> From: ShaoHe Feng <shaohef at 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 at linux.vnet.ibm.com>
> Signed-off-by: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
> ---
> ui/js/src/kimchi.api.js | 14 ++++++++++++++
> ui/js/src/kimchi.main.js | 11 ++++++++---
> 2 files changed, 22 insertions(+), 3 deletions(-)
>
> diff --git a/ui/js/src/kimchi.api.js b/ui/js/src/kimchi.api.js
> index 072d127..ad89880 100644
> --- a/ui/js/src/kimchi.api.js
> +++ b/ui/js/src/kimchi.api.js
> @@ -63,6 +63,20 @@ var kimchi = {
> },
>
> /**
> + * Get the i18 strings.
> + */
> + getI18n: function(suc, err, url, sync) {
> + kimchi.requestJSON({
> + url : url ? url : kimchi.url + '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 184029d..1e6602c 100644
> --- a/ui/js/src/kimchi.main.js
> +++ b/ui/js/src/kimchi.main.js
> @@ -247,9 +247,14 @@ 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;
> + buildTabs(initUI);
> + },
> + function(data){ //error
> + kimchi.message.error(data.responseJSON.reason);
> + });
> };
>
> kimchi.getHelp = function(e) {
More information about the Kimchi-devel
mailing list