From 0fd6447042683509d583e45a7059a2bea061ef77 Mon Sep 17 00:00:00 2001 From: Martin Kamerbeek Date: Thu, 7 May 2009 12:23:26 +0000 Subject: [PATCH] Internationalised the javascript part of the vendor payouts manager. --- lib/WebGUI/Shop/Vendor.pm | 2 + lib/WebGUI/i18n/English/Shop.pm | 78 +++++++++++++++++++++++++ www/extras/VendorPayout/vendorPayout.js | 59 ++++++++++++------- 3 files changed, 117 insertions(+), 22 deletions(-) diff --git a/lib/WebGUI/Shop/Vendor.pm b/lib/WebGUI/Shop/Vendor.pm index 4977cdade..24f4eb6bb 100644 --- a/lib/WebGUI/Shop/Vendor.pm +++ b/lib/WebGUI/Shop/Vendor.pm @@ -500,6 +500,7 @@ sub www_managePayouts { $style->setScript($url->extras('yui/build/datasource/datasource.js'), {type=>'text/javascript'}); $style->setScript($url->extras('yui/build/datatable/datatable-min.js'), {type=>'text/javascript'}); $style->setScript($url->extras('yui/build/button/button-min.js'), {type=>'text/javascript'}); + $style->setScript($url->extras('yui-webgui/build/i18n/i18n.js'), {type=>'text/javascript'}); $style->setScript($url->extras('VendorPayout/vendorPayout.js'), {type=>'text/javascript'}); # Add css for scheduled payout highlighting @@ -606,6 +607,7 @@ sub www_setPayoutStatus { $item->update({ vendorPayoutStatus => $status }); } + $session->http->setMimeType( 'text/plain' ); return $status; } diff --git a/lib/WebGUI/i18n/English/Shop.pm b/lib/WebGUI/i18n/English/Shop.pm index 86e202b3d..7929baa7a 100644 --- a/lib/WebGUI/i18n/English/Shop.pm +++ b/lib/WebGUI/i18n/English/Shop.pm @@ -1545,6 +1545,84 @@ our $I18N = { lastUpdated => 0, context => q|message that is displayed in the cart view screen|, }, + + 'schedule all button' => { + message => q|Schedule all|, + lastUpdated => 0, + context => 'Label for the schedule all button in the vendor payouts manager', + }, + + 'deschedule all button' => { + message => q|Deschedule all|, + lastUpdated => 0, + context => 'Label for the deschedule all button in the vendor payouts manager', + }, + + 'submit scheduled payouts button' => { + message => q|Submit Scheduled Payouts|, + lastUpdated => 0, + context => 'Label for the submit scheduled payouts button in the vendor payouts manager', + }, + + 'vendor id' => { + message => q|Vendor ID|, + lastUpdated => 0, + context => q|Table heading in the vendor payout manager.|, + }, + + 'vendor name' => { + message => q|Name|, + lastUpdated => 0, + context => q|Table heading in the vendor payout manager.|, + }, + + 'scheduled payout amount' => { + message => q|Scheduled for payout|, + lastUpdated => 0, + context => q|Table heading in the vendor payout manager.|, + }, + + 'not scheduled payout amount' => { + message => q|Not scheduled for payout|, + lastUpdated => 0, + context => q|Table heading in the vendor payout manager.|, + }, + + 'vp item id' => { + message => q|Item ID|, + lastUpdated => 0, + context => q|Table heading in the vendor payout manager.|, + }, + + 'vp item title' => { + message => q|Item name|, + lastUpdated => 0, + context => q|Table heading in the vendor payout manager.|, + }, + + 'vp item price' => { + message => q|Price|, + lastUpdated => 0, + context => q|Table heading in the vendor payout manager.|, + }, + 'vp item quantity' => { + message => q|Qty|, + lastUpdated => 0, + context => q|Table heading in the vendor payout manager.|, + }, + + 'vp item payout amount' => { + message => q|Payout amount|, + lastUpdated => 0, + context => q|Table heading in the vendor payout manager.|, + }, + + 'vp item payout status' => { + message => q|Payout status|, + lastUpdated => 0, + context => q|Table heading in the vendor payout manager.|, + }, + }; 1; diff --git a/www/extras/VendorPayout/vendorPayout.js b/www/extras/VendorPayout/vendorPayout.js index 3690c58a1..048c03cfa 100644 --- a/www/extras/VendorPayout/vendorPayout.js +++ b/www/extras/VendorPayout/vendorPayout.js @@ -6,6 +6,30 @@ WebGUI.VendorPayout = function ( containerId ) { var obj = this; this.container = document.getElementById( containerId ); + this.i18nObj = new WebGUI.i18n( { + namespaces : { + 'Shop' : [ + 'schedule all button', 'deschedule all button', 'submit scheduled payouts button', + 'vendor id', 'vendor name', 'scheduled payout amount', 'not scheduled payout amount', + 'vp item id', 'vp item title', 'vp item price', 'vp item quantity', 'vp item payout amount', + 'vp item payout status' + ] + }, + onpreload : { + fn : this.initialize, + obj : this, + override : true, + } + } ); + this.i18n = function ( key ) { + return this.i18nObj.get( 'Shop', key ) + }; + + return this; +} + +//---------------------------------------------------------------------------- +WebGUI.VendorPayout.prototype.initialize = function (aaa, bbb,ccc,ddd) { // Vendors data table this.vendorList = document.createElement('div'); this.container.appendChild( this.vendorList ); @@ -13,11 +37,11 @@ WebGUI.VendorPayout = function ( containerId ) { // (De)schedule buttons this.buttonDiv = document.createElement('div'); this.container.appendChild( this.buttonDiv ); - this.scheduleAllButton = new YAHOO.widget.Button({ label: 'Schedule all', container: this.buttonDiv }); - this.descheduleAllButton = new YAHOO.widget.Button({ label: 'Deschedule all', container: this.buttonDiv }); + this.scheduleAllButton = new YAHOO.widget.Button({ label: this.i18n( 'schedule all button' ), container: this.buttonDiv }); + this.descheduleAllButton = new YAHOO.widget.Button({ label: this.i18n( 'deschedule all button' ), container: this.buttonDiv }); // Submit button - this.submitPayoutsButton = new YAHOO.widget.Button({ label: 'Submit Scheduled Payouts', container: this.buttonDiv }); + this.submitPayoutsButton = new YAHOO.widget.Button({ label: this.i18n( 'submit scheduled payouts button' ), container: this.buttonDiv }); this.submitPayoutsButton.on( 'click', function () { YAHOO.util.Connect.asyncRequest( 'GET', '?shop=vendor;method=submitScheduledPayouts', { success: obj.initialize, @@ -29,17 +53,8 @@ WebGUI.VendorPayout = function ( containerId ) { this.payoutDetails = document.createElement('div'); this.container.appendChild( this.payoutDetails ); - this.itemBaseUrl = '?shop=vendor;method=payoutDataAsJSON;'; - // Initialise tables - this.initialize(); - - return this; -} - -//---------------------------------------------------------------------------- -WebGUI.VendorPayout.prototype.initialize = function () { this.initVendorList(); this.initPayoutDetails(); this.initButtons(); @@ -49,10 +64,10 @@ WebGUI.VendorPayout.prototype.initialize = function () { WebGUI.VendorPayout.prototype.initVendorList = function () { var obj = this; this.vendorSchema = [ - { key: 'vendorId' }, - { key: 'name' }, - { key: 'Scheduled' }, - { key: 'NotPaid' } + { key: 'vendorId', label : this.i18n( 'vendor id' ) }, + { key: 'name', label : this.i18n( 'vendor name' ) }, + { key: 'Scheduled', label : this.i18n( 'scheduled payout amount' ) }, + { key: 'NotPaid', label : this.i18n( 'not scheduled payout amount' ) } ]; // setup data source @@ -111,12 +126,12 @@ WebGUI.VendorPayout.prototype.refreshVendorRow = function () { WebGUI.VendorPayout.prototype.initPayoutDetails = function () { var obj = this; this.itemSchema = [ - { key: 'itemId' }, - { key: 'configuredTitle' }, - { key: 'price' }, - { key: 'quantity' }, - { key: 'vendorPayoutAmount' }, - { key: 'vendorPayoutStatus' } + { key: 'itemId', label : this.i18n( 'vp item id' ) }, + { key: 'configuredTitle', label : this.i18n( 'vp item title' ) }, + { key: 'price', label : this.i18n( 'vp item price' ) }, + { key: 'quantity', label : this.i18n( 'vp item quantity' ) }, + { key: 'vendorPayoutAmount', label : this.i18n( 'vp item payout amount' ) }, + { key: 'vendorPayoutStatus', label : this.i18n( 'vp item payout status' ) } ] // Create a row formatter to highlight Scheduled payouts