![]() |
Web Development »
Silverlight »
General
Intermediate
License: The Microsoft Public License (Ms-PL)
Silverlight 1.1 Hebrew and Arabic Language SupportBy Justin-Josef Angel [MVP]An article presenting Silverlight 1.1 Hebrew and Arabic language support |
C#, XML, .NET, Visual Studio, XAML, Dev
|
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||
Since I've started working on Silverlight projects in Israel, I've got one constant request from every customer - "We need Hebrew support!".
So, we developed a Silverlight component that enables just that - Hebrew & Arabic Right-to-left & Align-to-right support.
As we can all see - English text is aligned to the left and is written Left-to-Right (LTR).
But Hebrew and Arabic are written aligned to the right and are written Right-To-Left (RTL).
So let's look at the "Hello World!" samples In Blend:
(You can see that all texts are aligned-to-left and are formatted by the OS and not by Silverlight.)
However, when running the Silverlight 1.1 application in the browser, we get this:
What??? The texts are all jumbled!
Even if you don't know how to read Hebrew & Arabic - you can see that the two examples don't look the same.
Now let's see the Texts render properly using our new Silverlight 1.1 Hebrew & Arabic Language support:
We'll sum up the comparison we just did:
And without our Hebrew & Arabic support, we get this weird cross Hebrew and Arabic and English syntax:
TextBlocks TextBlocks on selected Canvases TextBlocks and Canvases from being RTLed RTLExtender TextBlocks TextBlock � animate only the parent Canvas TextBlock � rotate only the parent Canvas TextBlock by using C# code TextBlocks TextBlock TextWrapping property from the Default.

RTLExtender. (Asset Library -> Custom Controls -> RTLExtender).



RTLExtender has been added to the form, all TextBlocks will be Right-to-left and aligned to the right. TextBlock to the page, write some content in it.

TextBlock to our page with Hebrew/Arabic.


RTLExtender properties.

TargetTextBlocksName write the ID of the TextBlock.

Tbx1 should be the only TextBlock this RTLExtender RTL's.

TextBlocks like this:

TextBlock to the page (that's three by now), and group two of them to a Canvas.

Canvas.


TargetCanvasesName to our Canvas/es.

TextBlocks nested somewhere on this Canvas/es will be RTLed.

Canvas/es or TextBlock/s. We can exclude TextBlocks by using the ExcludedTextBlocksName:


Canvas/es.

Textblocks on myCanvas won't be RTLed, but all others on the page will.

RTLExtender to not RTL anything.


TextBlock to the Page and write one sentence that starts in Hebrew/Arabic, press Enter and one sentence that starts in English.


TextBlock's borders just so you see this feature better.



ForceAllParagraphsAsRTL to true.


All animations on TextBlocks that will be RTLed must be on the Parent Canvas or RTLExtender will throw an exception.


TextBlock that will be RTLed, and animate it somehow (let's rotate it):



TextBlock.TextBlock into a Canvas.

Canvas instead of the actual Textblock.

Becomes:


No RotateTransform is allowed on the TextBlock that will be RTLed or RTLExtender will throw an exception.
TextBlock and rotate it.



TextBlock inside a Parent Canvas and rotate it instead.



RTLExtender to RTL specific TextBlocks programmatically. (let's say TextBlocks on included TargetTextBlocksName or those dynamically created at runtime).


RTLExtender (or create a new one) and call the RTLTextBlock method.





TextBlock has been RTLed, it is no longer on the XAML page.


TextBlocks and removed from the parent children collection.

TextBlocks that replace our original TextBlocks like this:



TextBlock to our page.


TextBlock to have less width and more height (no breaklines were added mind you).

RTLExtender.

TextBlock to TextWrapping.NoWrap and it will be handled by the normal Silverlight NoWrap engine:
![]()

TextWrapping.WrapWithOverflow and it will extend slightly beyond the bounds of the TextBlock.
![]()

You will find bugs in this project.
Seriously, I'm not that smart that I can rebuild both Hebrew & Arabic RTL and align-to-right support in 10 hours.
Please go to the project's Codeplex page here and SilverlightRTL Create a new Issue.
Write what error you received, add the appropriate minimal & relevant code.
If something isn't working as you expect it to, tell me what you expect and what actually happens.
Attach a print screen if possible.
Additionally, you might want additional features (having the RTLExtender set its own fonts and download them from the server comes to mind).
Same goes, open a new issue and I'll do my best.
This project will surely undergo constant changes in the first 30-60 days after publishing.
If you're using this project, please signup to our RSS feed so you get notices.
RSS feed can be found here.
Here are my personal details just in case you feel the Codeplex page isn't sufficient:
Email: J@JustinAngel.Net
Cell: +972 546 567789
Office: +972 3 9504364
I'm serious about this, don't hesitate to contact me.
Well, that's about it.
| You must Sign In to use this message board. | ||||||||||||||||||||||
|
||||||||||||||||||||||
|
||||||||||||||||||||||
|
||||||||||||||||||||||
|
||||||||||||||||||||||
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 31 Jan 2008 Editor: Deeksha Shenoy |
Copyright 2008 by Justin-Josef Angel [MVP] Everything else Copyright © CodeProject, 1999-2009 Web15 | Advertise on the Code Project |