From ee4c409e5627e1591c4a66d25be1a2a373450fca Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Fri, 3 Oct 2008 00:48:34 +0000 Subject: [PATCH] ENHANCEMENT Started using ss.i18n clientside javascript in LeftAndMain classes (only a fraction made translatable) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@63569 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- code/LeftAndMain.php | 3 ++- javascript/CMSMain_left.js | 37 ++++++++++++++++++++------------- javascript/CMSMain_right.js | 6 +++--- javascript/LeftAndMain.js | 5 ++++- javascript/LeftAndMain_left.js | 4 ++-- javascript/LeftAndMain_right.js | 6 +++--- javascript/lang/de_DE.js | 23 ++++++++++++++++++++ javascript/lang/en_US.js | 25 ++++++++++++++++++++++ 8 files changed, 85 insertions(+), 24 deletions(-) create mode 100644 javascript/lang/de_DE.js create mode 100644 javascript/lang/en_US.js diff --git a/code/LeftAndMain.php b/code/LeftAndMain.php index e47e3c7b..dd159faf 100644 --- a/code/LeftAndMain.php +++ b/code/LeftAndMain.php @@ -126,6 +126,7 @@ class LeftAndMain extends Controller { Requirements::javascript(THIRDPARTY_DIR . '/loader.js'); Requirements::javascript(THIRDPARTY_DIR . '/hover.js'); Requirements::javascript(THIRDPARTY_DIR . '/layout_helpers.js'); + Requirements::javascript(SAPPHIRE_DIR . "/javascript/i18n.js"); Requirements::javascript(MCE_ROOT . 'tiny_mce_src.js'); Requirements::javascript(CMS_DIR . '/javascript/ImageEditor/Activator.js'); @@ -584,7 +585,7 @@ JS; */ public function getActionUpdateJS($record) { // Get the new action buttons - + $tempForm = $this->getEditForm($record->ID); $actionList = ''; foreach($tempForm->Actions() as $action) { diff --git a/javascript/CMSMain_left.js b/javascript/CMSMain_left.js index 301cffd5..db982921 100755 --- a/javascript/CMSMain_left.js +++ b/javascript/CMSMain_left.js @@ -71,10 +71,10 @@ addpage.prototype = { var parentID = st.getIdxOf(st.firstSelected()); // TODO: Remove 'new-' code http://open.silverstripe.com/ticket/875 if(parentID && parentID.substr(0,3) == 'new') { - alert("You have to save a page before adding children underneath it"); + alert(ss.i18n._t('CMSMAIN.WARNINGSAVEPAGESBEFOREADDING')); } else if( Element.hasClassName( st.firstSelected(), "nochildren" ) ) { - alert("You can't add children to the selected node" ); + alert(ss.i18n._t('CMSMAIN.CANTADDCHILDREN') ); } else { $(_HANDLER_FORMS.addpage).elements.ParentID.value = parentID ? parentID : 0; @@ -93,7 +93,7 @@ addpage.prototype = { }, showAddPageError: function(response) { - errorMessage('Error adding page', response); + errorMessage(ss.i18n._t('CMSMAIN.ERRORADDINGPAGE'), response); } } @@ -180,10 +180,13 @@ showonlydrafts.prototype = { Behaviour.apply(); $('SiteTreeIsFiltered').value = 1; $('batchactions').multiselectTransform(); - statusMessage('Filtered tree to only show changed pages','good'); + statusMessage(ss.i18n._t('CMSMAIN.FILTEREDTREE'),'good'); }, onFailure : function(response) { - errorMessage('Could not filter tree to only show changed pages
' + response.responseText); + errorMessage(ss.i18n.printf( + ss.i18n._t('CMSMAIN.ERRORFILTERPAGES'), + response.responseText + )); } }); } else { @@ -270,10 +273,13 @@ batchActionGlobals = { Behaviour.apply(); $('SiteTreeIsFiltered').value = 0; $('batchactions').multiselectTransform(); - statusMessage('Unfiltered tree','good'); + statusMessage(ss.i18n._t('CMSMAIN.SUCCESSUNFILTER'),'good'); }, onFailure : function(response) { - errorMessage('Could not unfilter site tree
' + response.responseText); + errorMessage(ss.i18n.printf( + ss.i18n._t('CMSMAIN.ERRORUNFILTER'), + response.responseText + )); } }); } @@ -291,7 +297,7 @@ publishpage.prototype = { if(csvIDs) { this.elements.csvIDs.value = csvIDs; - statusMessage('Publishing pages...'); + statusMessage(ss.i18n._t('CMSMAIN.PUBLISHINGPAGES')); // Put an AJAXY loading icon on the button $('action_publish_selected').className = 'loading'; @@ -302,11 +308,11 @@ publishpage.prototype = { treeactions.closeSelection($('batchactions')); }, onFailure : function(response) { - errorMessage('Error publishing pages', response); + errorMessage(ss.i18n._t('CMSMAIN.ERRORPUBLISHING'), response); } }); } else { - alert("Please select at least 1 page."); + alert(ss.i18n._t('CMSMAIN.SELECTONEPAGE')); } return false; @@ -325,10 +331,13 @@ deletepage.prototype = { if(csvIDs || batchActionGlobals.newNodes.length > 0) { batchActionGlobals.count += batchActionGlobals.newNodes.length; - if(confirm("Do you really want to delete the " + batchActionGlobals.count + " marked pages?")) { + if(confirm(ss.i18n.printf( + ss.i18n._t('CMSMAIN.REALLYDELETEPAGES'), + batchActionGlobals.count + ))) { this.elements.csvIDs.value = csvIDs; - statusMessage('Deleting pages...'); + statusMessage(ss.i18n._t('CMSMAIN.DELETINGPAGES')); // TODO: Remove 'new-' code http://open.silverstripe.com/ticket/875 for( var idx = 0; idx < batchActionGlobals.newNodes.length; idx++ ) { var newNode = $('sitetree').getTreeNodeByIdx( batchActionGlobals.newNodes[idx] ); @@ -351,13 +360,13 @@ deletepage.prototype = { treeactions.closeSelection($('batchactions')); }, onFailure : function(response) { - errorMessage('Error deleting pages', response); + errorMessage(ss.i18n._t('CMSMAIN.ERRORDELETINGPAGES'), response); } }); } } else { - alert("Please select at least 1 page."); + alert(ss.i18n._t('CMSMAIN.SELECTONEPAGE')); } return false; diff --git a/javascript/CMSMain_right.js b/javascript/CMSMain_right.js index 5cd89dfe..6318d328 100755 --- a/javascript/CMSMain_right.js +++ b/javascript/CMSMain_right.js @@ -1,16 +1,16 @@ function action_publish_right() { - $('Form_EditForm_action_publish').value = 'Publishing...'; + $('Form_EditForm_action_publish').value = ss.i18n._t('CMSMAIN.PUBLISHING'); $('Form_EditForm_action_publish').className = 'action loading'; var publish = true; $('Form_EditForm').save(false, null, 'save', publish); } function action_revert_right() { - $('Form_EditForm_action_revert').value = 'Restoring...'; + $('Form_EditForm_action_revert').value = ss.i18n._t('CMSMAIN.RESTORING'); $('Form_EditForm_action_revert').className = 'action loading'; Ajax.SubmitForm('Form_EditForm', 'action_revert', { onSuccess : Ajax.Evaluator, onFailure : function(response) { - errorMessage('Error reverting to live content', response); + errorMessage(ss.i18n._t('CMSMAIN.ERRORREVERTING'), response); } }); } diff --git a/javascript/LeftAndMain.js b/javascript/LeftAndMain.js index 5c426bd8..3259b6ed 100644 --- a/javascript/LeftAndMain.js +++ b/javascript/LeftAndMain.js @@ -279,7 +279,7 @@ function prepareAjaxActions(actions, formName, tabName) { if(window[this.name + '_' + tabName]) { window[this.name + '_' + tabName](e); } else { - statusMessage(ingize(this.value)); + statusMessage('...'); Ajax.SubmitForm(this.ownerForm, this.name, { onSuccess: Ajax.Evaluator, onFailure: ajaxErrorHandler @@ -291,6 +291,9 @@ function prepareAjaxActions(actions, formName, tabName) { } } +/** + * @deprecated 2.3 Please use ss.i18n + */ function ingize(val) { var ingWord, suffix; if(!val) val = "process"; diff --git a/javascript/LeftAndMain_left.js b/javascript/LeftAndMain_left.js index 2d5707de..3e5a3b0a 100755 --- a/javascript/LeftAndMain_left.js +++ b/javascript/LeftAndMain_left.js @@ -336,7 +336,7 @@ SiteTreeNode.prototype = { var currentlyOpenPageID = 0; if($('Form_EditForm').elements.ID) currentlyOpenPageID = $('Form_EditForm').elements.ID.value; - statusMessage('saving...', '', true); + statusMessage(ss.i18n._t('CMSMAIN.SAVING'), '', true); new Ajax.Request(SiteTreeHandlers.parentChanged_url, { method : 'post', postBody : 'ID=' + node.getIdx() + '&ParentID=' + newParent.getIdx() + '&CurrentlyOpenPageID=' + currentlyOpenPageID, @@ -355,7 +355,7 @@ SiteTreeNode.prototype = { * movedNode is the node that actually got moved to trigger this resorting */ onOrderChanged : function(nodeList, movedNode) { - statusMessage('saving...', '', true); + statusMessage(ss.i18n._t('CMSMAIN.SAVING'), '', true); var i, parts = Array(); sort = 0; diff --git a/javascript/LeftAndMain_right.js b/javascript/LeftAndMain_right.js index 0019e9a3..a252b7bf 100755 --- a/javascript/LeftAndMain_right.js +++ b/javascript/LeftAndMain_right.js @@ -184,7 +184,7 @@ CMSForm.prototype = { data += '&publish=1'; } - statusMessage("Saving...", null, true); + statusMessage(ss.i18n._t('CMSMAIN.SAVING'), null, true); new Ajax.Request(this.action, { method : this.method, postBody: data, @@ -311,7 +311,7 @@ CMSRightForm.applyTo('#Form_EditForm', 'right'); function action_save_right() { _AJAX_LOADING = true; - $('Form_EditForm_action_save').value = 'Saving...'; + $('Form_EditForm_action_save').value = ss.i18n._t('CMSMAIN.SAVING'); $('Form_EditForm_action_save').className = 'action loading'; $('Form_EditForm').save(false); } @@ -411,7 +411,7 @@ function autoSave(confirmation, callAfter) { // save is still used if confirmation = false var options = { save: function() { - statusMessage('saving...', '', true); + statusMessage(ss.i18n._t('CMSMAIN.SAVING'), '', true); var i; for(i=0;i<__forms.length;i++) { if(__forms[i].isChanged && __forms[i].isChanged()) { diff --git a/javascript/lang/de_DE.js b/javascript/lang/de_DE.js new file mode 100644 index 00000000..11fc53d2 --- /dev/null +++ b/javascript/lang/de_DE.js @@ -0,0 +1,23 @@ +if(typeof(ss) == 'undefined' || typeof(ss.i18n) == 'undefined') { + console.error('Class ss.i18n not defined'); +} else { + ss.i18n.addDictionary('de_DE', { + 'CMSMAIN.WARNINGSAVEPAGESBEFOREADDING' : "Sie müssen diese Seite speichern bevor Unterseiten hingefügt werden können", + 'CMSMAIN.CANTADDCHILDREN' : "Unterseiten nicht erlaubt", + 'CMSMAIN.ERRORADDINGPAGE' : 'Fehler beim Hinzufügen der Seite', + 'CMSMAIN.FILTEREDTREE' : 'Gefilterter Seitenbaum zeigt nur Änderungen', + 'CMSMAIN.ERRORFILTERPAGES' : 'Konnte Seitenbaum nicht filtern
%s', + 'CMSMAIN.ERRORUNFILTER' : 'Konnte Filterung des Seitenbaumes nicht aufheben
%s', + 'CMSMAIN.ERRORUNFILTER' : 'Filterung des Seitenbaumes zurückgesetzt', + 'CMSMAIN.PUBLISHINGPAGES' : 'Publiziere Seiten...', + 'CMSMAIN.SELECTONEPAGE' : "Bitte mindestens eine Seite auswählen", + 'CMSMAIN.ERRORPUBLISHING' : 'Fehler beim Veröffentlichen der Seiten', + 'CMSMAIN.REALLYDELETEPAGE' : "Wollen Sie wirklich %s Seiten löschen?", + 'CMSMAIN.DELETINGPAGES' : 'Lösche Seiten...', + 'CMSMAIN.ERRORDELETINGPAGES': 'Fehler beim Löschen der Seiten', + 'CMSMAIN.PUBLISHING' : 'Veröffentliche...', + 'CMSMAIN.RESTORING': 'Wiederherstellen...', + 'CMSMAIN.ERRORREVERTING': 'Fehler beim Wiederherstellen des Live-Inhaltes', + 'CMSMAIN.SAVING' : 'Sichern...' + }); +} \ No newline at end of file diff --git a/javascript/lang/en_US.js b/javascript/lang/en_US.js new file mode 100644 index 00000000..ab98426b --- /dev/null +++ b/javascript/lang/en_US.js @@ -0,0 +1,25 @@ +if(typeof(ss) == 'undefined' || typeof(ss.i18n) == 'undefined') { + console.error('Class ss.i18n not defined'); +} else { + ss.i18n.addDictionary('en_US', { + 'CMSMAIN.WARNINGSAVEPAGESBEFOREADDING' : "You have to save a page before adding children underneath it", + 'CMSMAIN.CANTADDCHILDREN' : "You can't add children to the selected node", + 'CMSMAIN.ERRORADDINGPAGE' : 'Error adding page', + 'CMSMAIN.FILTEREDTREE' : 'Filtered tree to only show changed pages', + 'CMSMAIN.ERRORFILTERPAGES' : 'Could not filter tree to only show changed pages
%s', + 'CMSMAIN.ERRORUNFILTER' : 'Could not unfilter site tree
%s', + 'CMSMAIN.ERRORUNFILTER' : 'Unfiltered tree', + 'CMSMAIN.PUBLISHINGPAGES' : 'Publishing pages...', + 'CMSMAIN.SELECTONEPAGE' : "Please select at least 1 page.", + 'CMSMAIN.ERRORPUBLISHING' : 'Error publishing pages', + 'CMSMAIN.REALLYDELETEPAGE' : "Do you really want to delete the %s marked pages?", + 'CMSMAIN.DELETINGPAGES' : 'Deleting pages...', + 'CMSMAIN.ERRORDELETINGPAGES': 'Error deleting pages', + 'CMSMAIN.PUBLISHING' : 'Publishing...', + 'CMSMAIN.RESTORING': 'Restoring...', + 'CMSMAIN.ERRORREVERTING': 'Error reverting to live content', + 'CMSMAIN.SAVING' : 'saving...', + + + }); +} \ No newline at end of file