I've tried loading the ar-AR.tdf dictionary that can be downloaded into the editor's DocumentSpellChecker, and I've tried setting the spell checker's locale to AR, but neither have any effect. I've also tried creating a class that implements ISpellChecker, and I've found that CheckWordIsCorrect is never getting called for Arabic words, though it does seem to be getting called for any Latin-character words.
The same problem occurs with Hebrew text, though spell checking is working with Russian.
Is there a way to get the WPF RadRichTextBox to spell check Arabic words? I'm using the .NET 4.0 Q3 2012 version of the WPF components, though I've tried the Q1 2013 release for both .net 4 and .net 4.5 and the issue still remains.
20 Answers, 1 is accepted
Unfortunately, spell checking does not work for languages with RTL direction. We have such a feature in our to-do list and it may be scheduled for the next major release - 2013 Q2. If that happens, it would be possible to spell check words in Hebrew and Arabic.
Iva Toteva
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
Thank you for the reply. Is there a public issue for this that I can vote for and track?
I recently replaced the built-in editor for a project to use the Telerik RichTextBox primarily because of the much better bidirectional text support in the Telerik editor from the component I was using previously. Allowing RTL spell checking is important for providing full support to RTL language users.
Thanks,
Ryan
RTL languages use characters that are treated as upper case. RadRichTextBox, on the other hand, does not spell check words that contain only upper case letters. Once an option to spell check such words is introduced, it would be possible to spell check RTL languages as well.
Here is the PITS issue for spell checking all-uppercase letters: http://www.telerik.com/support/pits.aspx#/public/wpf/14369.
Iva Toteva
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
onlyUpperLetters = onlyUpperLetters && !char.IsLower(c);
The issue is that IsLower will return false for Arabic and Hebrew languages, because both of these languages don't have a concept of upper or lower case letters. Similarily, char.IsUpper(c) will always return false for these languages for the same reason.
A simple fix to the issue of spellchecking not working for these languages would be to change the above statement to be:
onlyUpperLetters = onlyUpperLetters && char.IsUpper(c);
This would keep the same behaviour as before, but wouldn't omit words in alphabets that don't have case-sensitive characters.
I believe this is a bug that could be easily addressed. Enabling the spellchecking of all upper-case words would be more of a work-around to this issue.
Actually spell-checking words that are all uppercase should be an option, so that the spell checking of abbreviations could be suppressed. We have it in our to-do list and the starting point is indeed the place in the code you pointed out. However, other logic must also be revised so that the spell checking decorations could appear correctly on RTL text.
Given the fact that it should be an option, we treat is as a new feature. In any case, we will do our best to include it in the next official release.
Iva Toteva
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
I'm also facing the same problem. except the RTL words it is giving suggestions.
I'm using the .NET 4.0 and Q2 2013 version of Rad silverlight components. still i'm not able to get the suggestions for Arabic and Hebrew language words. The issue still remains
Plaese any suggestions?..
Thanks,
Chandrashekar
Currently, the feature is not available. We are working on its implementation and it will be included in the next Q3 2013 release expected in October.
Let us know if you have further comments or questions.
Regards,
Petya
Telerik
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Regards
Kushagra
As mentioned in my previous post and visible from the respective PITS item here, the feature is already implemented. After it passes the needed testing process it will be released with the Q3 2013 release.
Let us know if you have other comments.
Regards,
Petya
Telerik
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Is there any news available for Arabic dictionary support in Q3 2013 . If yes kindly guide me to the steps on how to use it. We have our customers eagerly waiting for this feature.
Regards,
Kushagra
I’m very happy to inform you, that Telerik RadRichTextBox already supports spellchecking for Arabic text. Please take a look at this article for reference how to use RadRichTextBox Spellcheck. A list of dictionaries could be found at this forum post, as well as the needed Arabic dictionary.
In a nutshell, a dictionary could be added through the RadDictionary class which supports the loading of a dictionary directly from TDF files.
I hope this is helpful!
Please let me know if I can provide any further assistance.
Regards,
Yancho
Telerik
I tried every step which you suggested and still I am not able to get working solution for the Arabic Dictionary.It doesnt detect arabic at all. I am attaching my sample project with this post. Please see where am I going wrong with this. This is with Q3 binaries
This is my Code:
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
//using System.Windows.Navigation;
using System.Windows.Shapes;
using Telerik.Windows.Documents.Proofing;
namespace Q3RichText
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
//Here we take the IControlSpellChecker instance for the TextBoxControl
((DocumentSpellChecker)this.radRichTextBox.SpellChecker).AddDictionary(new RadEn_USDictionary(), new CultureInfo("ar-AE"));
((DocumentSpellChecker)this.radRichTextBox.SpellChecker).SpellCheckingCulture = new CultureInfo("ar-AE");
//IControlSpellChecker controlSpellchecker = ControlSpellCheckersManager.GetControlSpellChecker(typeof(RichTextBox));
//We get the SpellChecker property and cast it to DocumentSpellChecker(which inherits from ISpellChecker)
// DocumentSpellChecker documentSpellChecker = (DocumentSpellChecker)controlSpellchecker.SpellChecker;
//Then we add the class deriving from RadDictionary and the Culture info to the DocumentSpellChecker(we are using Spanish again for the example)
//documentSpellChecker.AddDictionary(new RadEs_ARDictionary(), new System.Globalization.CultureInfo("ar-AE"));
}
}
public class RadEs_ARDictionary : RadDictionary
{
public RadEs_ARDictionary()
{
System.Reflection.Assembly assembly = this.GetType().Assembly;
Stream stream = assembly.GetManifestResourceStream(assembly.GetName().Name + ".ar-AR.tdf");
//Stream stream = Application.GetResourceStream(new Uri(";component/es-ES.tdf", UriKind.Relative)).Stream;
this.Load(stream);
}
protected override void EnsureDictionaryLoadedOverride()
{
//System.Reflection.Assembly assembly = this.GetType().Assembly;
//Stream stream = assembly.GetManifestResourceStream(assembly.GetName().Name + "ar-AR.tdf");
////Stream stream = Application.GetResourceStream(new Uri(";component/es-ES.tdf", UriKind.Relative)).Stream;
//this.Load(stream);
}
}
}
Regards,
kushagra
Regards,
Kushagra
Please find attached a demo project which illustrates how to add an Arabic dictionary and enable spellchecking for text in this language. Note that the SpellCheckUppercaseWords property of the spellchecker's settings needs to be set for this to work.
Additionally, you need to make sure the CurrentCulture is set. The attached project shows two ways of doing that:
- First option is related to setting the culture of the CurrentThread as in the code-snippet below:
Thread.CurrentThread.CurrentCulture =
new
CultureInfo(
"ar-DZ"
);
- Second option, you could set the SpellCheckingCulture like this:
((DocumentSpellChecker)
this
.radRichTextBox.SpellChecker).SpellCheckingCulture =
new
CultureInfo(
"ar-DZ"
);
I hope this helps!
Let me know if you have other comments or questions. I would be glad to provide any assistance!
Regards,
Yancho
Telerik
That solves most part of it. But can you also guide me on how to use both english and arabic dictionaries together. As I am only able to use one at a time
Regards,
Kushagra
Unfortunately, RadRichTextBox does not support spellchecking for more than one language at the same time. The spellchecking functionality depends on the CurrentCulture in which the RadRichTextBox is running and it will automatically switch between all dictionaries in the DocumentSpellCkecker collection.
RadRichTextBox comes with a default English spellchecking dictionary which is ready to use if a reference to Telerik.Windows.Documents.Proofing.Dictionaries.En-US.dll is added. Any other dictionary could be added to the DocumentSpellCkecker collection of dictionaries (what we did in the demo project).
Please be aware, that because of the specificity of Arabic language should be done some additional changes. If you are going to use both English and Arabic dictionary, but one at a time, I would recommend you check the CurrentCulture and if it corresponds to “ar-DZ” culture to set the Arabic dictionary. The following code-snippet demonstrates how this could be achieved:
public
MainWindow()
{
InitializeComponent();
string
currentCulture = Thread.CurrentThread.CurrentCulture.Name;
if
(currentCulture ==
"ar-DZ"
)
{
RadRichTextBox.DefaultTextRenderingMode = Telerik.Windows.Documents.UI.TextBlocks.TextBlockRenderingMode.TextBlockWithPropertyCaching;
ChangeRadRichTextBoxFlowDirection();
this
.LoadDictionary();
}
}
private
void
LoadDictionary()
{
Stream stream = Application.GetResourceStream(
new
Uri(
"/RadRichTextBoxArabicSpellchecking;component/ar-AR.tdf"
, UriKind.RelativeOrAbsolute)).Stream;
RadDictionary dictionary =
new
RadDictionary();
dictionary.Load(stream);
((DocumentSpellChecker)
this
.radRichTextBox.SpellChecker).AddDictionary(dictionary,
new
CultureInfo(
"ar-DZ"
));
((DocumentSpellChecker)
this
.radRichTextBox.SpellChecker).Settings.SpellCheckUppercaseWords =
true
;
}
private
void
ChangeRadRichTextBoxFlowDirection()
{
this
.radRichTextBox.ChangeParagraphFlowDirection(FlowDirection.RightToLeft);
}
I hope this helps!
Do not hesitate to contact us back.
Regards,
Yancho
Telerik
Thanks for the reply. I tried one thing and I think I was successful in achieving what I want to achieve. I downloaded the en-us.tdf file,opened it in notepad and copied the whole content and appended it to the ar-AR.tdf file. Then I set the culture to use ar-AE specifically exactly what we did in example we worked together on. Thus I was able to get both english and arabic support. I think it work pretty well. Not sure that if there are any short comings of this approach. Yeah if new version of dictionary comes I will have to replace old file and repeat the exercise again. But, thats not a big issue for us. This way I can offer spell check on both the languages to the clients.
If you think that is a neat enough solution, I can help you with a sample application for it. The only thing is that I am not able to upload the project here. If I am able to attach the solution in this forum , It will help a lot of people in the future.
Regards.
Kushagra
tiwari.kushagra@gmail.com
Regards,
Kushagra
I’m very happy that you have managed to achieve your goal!
Your solution works for your scenario because both languages don’t use common letters for words building. I’m not familiar of any short comings of this approach. Indeed, it’s a very custom scenario which allows spellchecking for more than one language at the same time. If you'd like to you can create a code library with your solution here.
Thank you for your contribution to our forum community.
It would be helpful to other users who would try to implement such functionality.
Regards,
Yancho
Telerik
DevCraft Q1'14 is here! Join the free online conference to see how this release solves your top-5 .NET challenges. Reserve your seat now!