Index: _source/lang/en.js
===================================================================
--- _source/lang/en.js	(revision 5640)
+++ _source/lang/en.js	(revision )
@@ -744,5 +744,11 @@
 	},
 
 	toolbarCollapse	: 'Collapse Toolbar',
-	toolbarExpand	: 'Expand Toolbar'
+	toolbarExpand	: 'Expand Toolbar',
+
+	bidiswitch :
+	{
+		ltr :"Switch to LTR text direction",
+		rtl : "Switch to RTL text direction"
+	}
 };
Index: _source/plugins/bidiswitch/plugin.js
===================================================================
--- _source/plugins/bidiswitch/plugin.js	(revision )
+++ _source/plugins/bidiswitch/plugin.js	(revision )
@@ -0,0 +1,95 @@
+/*
+Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
+For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+(function(){
+
+	function onSelectionChange( evt )
+	{
+		var command = evt.editor.getCommand( 'rtlSwitch' );
+		command.state = getState( evt.editor, evt.data.path, 'rtl' );
+		command.fire( 'state' );
+
+		command = evt.editor.getCommand( 'ltrSwitch' );
+		command.state = getState( evt.editor, evt.data.path, 'ltr' );
+		command.fire( 'state' );
+	}
+	
+	function getState( editor, path, dir )
+	{
+		var firstBlock = path.block || path.blockLimit;
+
+		if ( !firstBlock || firstBlock.getName() == 'body' )
+			return CKEDITOR.TRISTATE_OFF;
+
+		return ( firstBlock.getAttribute( 'dir' ) == dir ) ?
+			CKEDITOR.TRISTATE_ON : CKEDITOR.TRISTATE_OFF;
+	}
+
+	function bidiCommand( dir )
+	{
+		return function( editor )
+		{
+			var selection = editor.getSelection(),
+				enterMode = editor.config.enterMode,
+				ranges = editor.getSelection().getRanges();
+
+			// Creates bookmarks for selection, as we may split some blocks.
+			var bookmarks = selection.createBookmarks();
+
+			if ( ranges )
+			{
+				var iterator,
+					block;
+
+				for ( var i = ranges.length - 1 ; i >= 0 ; i-- )
+				{
+					iterator = ranges[ i ].createIterator();
+					iterator.enlargeBr = enterMode != CKEDITOR.ENTER_BR;
+
+					while ( ( block = iterator.getNextParagraph( enterMode == CKEDITOR.ENTER_P ? 'p' : 'div' ) ) )
+					{
+						if ( block.hasAttribute( 'dir' ) && block.getAttribute( 'dir' ).toLowerCase()  == dir )
+							block.removeAttribute( 'dir' );
+						else
+							block.setAttribute( 'dir', dir );
+					}
+				}
+
+				editor.focus();
+				editor.forceNextSelectionCheck();
+				// Restore selection position.
+				selection.selectBookmarks( bookmarks );
+			}
+		};
+	}
+
+	CKEDITOR.plugins.add( 'bidiswitch',
+	{
+		requires : [ 'styles', 'button' ],
+
+		init : function( editor )
+		{
+			// All buttons use the same code to register. So, to avoid
+			// duplications, let's use this tool function.
+			var addButtonCommand = function( buttonName, buttonLabel, commandName, commandExec )
+			{
+				editor.addCommand( commandName, new CKEDITOR.command( editor, { exec : commandExec }) );
+
+				editor.ui.addButton( buttonName,
+					{
+						label : buttonLabel,
+						command : commandName
+					});
+			};
+
+			var lang = editor.lang.bidiswitch;
+
+			addButtonCommand( 'BidiRtl', lang.rtl, 'rtlSwitch', bidiCommand( 'rtl' ) );
+			addButtonCommand( 'BidiLtr', lang.ltr, 'ltrSwitch', bidiCommand( 'ltr' ) );
+
+			editor.on( 'selectionChange', onSelectionChange );
+		}
+	});
+	
+})();
