From ef08d0d4812289edef942d633b7cb78be8f4a157 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Thu, 21 Apr 2011 19:54:18 -0700 Subject: [PATCH] i18n the controls for the JsonTable form plugin. Fixes bug #12116 --- docs/changelog/7.x.x.txt | 1 + lib/WebGUI/Form/JsonTable.pm | 11 +++++++- lib/WebGUI/i18n/English/WebGUI.pm | 18 +++++++++++++ www/extras/yui-webgui/build/form/jsontable.js | 25 +++++++++++++++---- 4 files changed, 49 insertions(+), 6 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index c4292974e..f932d2b82 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -1,5 +1,6 @@ 7.10.15 - fixed #12117: Thingy - www_searchViaAjax broken + - fixed #12116: JsonTable form control needs i18n 7.10.14 - fixed #12094: Cannot enter in Macros in URLs inside TinyMCE. diff --git a/lib/WebGUI/Form/JsonTable.pm b/lib/WebGUI/Form/JsonTable.pm index 7511766d5..9e8403906 100644 --- a/lib/WebGUI/Form/JsonTable.pm +++ b/lib/WebGUI/Form/JsonTable.pm @@ -137,6 +137,10 @@ Send JS required for this plugin. sub headTags { my $self = shift; my ( $url, $style ) = $self->session->quick(qw( url style )); + $style->setScript( + $url->extras('yui/build/connect/connect-min.js'), + { type => 'text/javascript' }, + ); $style->setScript( $url->extras('yui/build/yahoo-dom-event/yahoo-dom-event.js'), { type => 'text/javascript' }, @@ -145,6 +149,10 @@ sub headTags { $url->extras('yui/build/json/json-min.js'), { type => 'text/javascript' }, ); + $style->setScript( + $url->extras('yui-webgui/build/i18n/i18n.js'), + { type => 'text/javascript' }, + ); $style->setScript( $url->extras('yui-webgui/build/form/jsontable.js'), { type => 'text/javascript' }, @@ -162,6 +170,7 @@ Renders an input tag of type text. sub toHtml { my $self = shift; my $session = $self->session; + my $i18n = WebGUI::International->new($session, 'WebGUI'); my ( $url, $style ) = $session->quick(qw( url style )); my $value = $self->fixMacros($self->fixQuotes($self->fixSpecialCharacters($self->getOriginalValue))); my $output = ''; @@ -176,7 +185,7 @@ sub toHtml { # Buttons to add rows in the table footer my $cols = scalar @{ $self->get('fields') } + 1; # Extra column for buttons $output .= '' - . '' + . '' . '' ; diff --git a/lib/WebGUI/i18n/English/WebGUI.pm b/lib/WebGUI/i18n/English/WebGUI.pm index 4d23d74f1..5485ada82 100644 --- a/lib/WebGUI/i18n/English/WebGUI.pm +++ b/lib/WebGUI/i18n/English/WebGUI.pm @@ -4725,6 +4725,24 @@ Users may override this setting in their profile. context => 'Description for pick style template page', }, + 'Up' => { + message => 'Up', + lastUpdate => 0, + context => 'Up, as in move up.', + }, + + 'Down' => { + message => 'Down', + lastUpdate => 0, + context => 'Down, as in move down.', + }, + + 'Add' => { + message => 'Add', + lastUpdate => 0, + context => 'Add, as in to append or add more', + }, + }; 1; diff --git a/www/extras/yui-webgui/build/form/jsontable.js b/www/extras/yui-webgui/build/form/jsontable.js index bb21b4abf..62b9124c7 100644 --- a/www/extras/yui-webgui/build/form/jsontable.js +++ b/www/extras/yui-webgui/build/form/jsontable.js @@ -60,8 +60,21 @@ WebGUI.Form.JsonTable }, this, true ); - - this.init(); + this.i18n + = new WebGUI.i18n( { + namespaces : { + 'WebGUI' : [ + "576", + "Up", + "Down" + ] + }, + onpreload : { + fn : WebGUI.Form.JsonTable.prototype.init, + obj : this, + override : true + } + } ); return this; }; @@ -69,6 +82,7 @@ WebGUI.Form.JsonTable /**************************************************************************** * addActions( row ) * Add the row actions to the given row + * Delay creating this so that the i18n object exists */ WebGUI.Form.JsonTable.prototype.addActions = function (row) { @@ -76,7 +90,7 @@ WebGUI.Form.JsonTable.prototype.addActions var buttonCell = row.lastChild; var deleteButton = document.createElement('input'); deleteButton.type = "button"; - deleteButton.value = "Delete"; + deleteButton.value = this.i18n.get('WebGUI', '576'); YAHOO.util.Event.addListener( deleteButton, "click", function (e) { this.deleteRow( row ); @@ -87,7 +101,7 @@ WebGUI.Form.JsonTable.prototype.addActions var moveUpButton = document.createElement('input'); moveUpButton.type = "button"; - moveUpButton.value = "Up"; + moveUpButton.value = this.i18n.get('WebGUI', 'Up'); YAHOO.util.Event.addListener( moveUpButton, "click", function (e) { this.moveRowUp( row ); @@ -98,7 +112,7 @@ WebGUI.Form.JsonTable.prototype.addActions var moveDownButton = document.createElement('input'); moveDownButton.type = "button"; - moveDownButton.value = "Down"; + moveDownButton.value = this.i18n.get('WebGUI', 'Down'); YAHOO.util.Event.addListener( moveDownButton, "click", function (e) { this.moveRowDown( row ); @@ -164,6 +178,7 @@ WebGUI.Form.JsonTable.prototype.init } } } + }; /****************************************************************************