This is a migrated thread and some comments may be shown as answers.

Spellchecking for Arabic

20 Answers 149 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Ryan
Top achievements
Rank 1
Ryan asked on 28 Mar 2013, 07:52 PM
I've been trying to get spell checking working for Arabic text entered into a RadRichTextBox, however it never appears to check the spelling of any Arabic words entered.  No Arabic words are getting marked as misspelled.

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

Sort by
0
Iva Toteva
Telerik team
answered on 01 Apr 2013, 08:32 AM
Hi Ryan,

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.

Kind regards,
Iva Toteva
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Ryan
Top achievements
Rank 1
answered on 01 Apr 2013, 02:12 PM
Hi Iva,

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
0
Iva Toteva
Telerik team
answered on 02 Apr 2013, 03:25 PM
Hello 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.

All the best,
Iva Toteva
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Eric
Top achievements
Rank 1
answered on 02 Apr 2013, 05:39 PM
My team is currently having the same issue with spell checking RTL languages.  This issues is a show stopper and is currently blocking us from proceeding.  Is there a way we can get this issue resolved sooner?
0
Ryan
Top achievements
Rank 1
answered on 03 Apr 2013, 02:16 PM
To expand on the issue that Eric points out in the remarks on the issue tracker item, Looking at the decompiled ParagraphLayoutBox class, the problem is in the internal GetWordsFromText method, specifically the line:

  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.
0
Accepted
Iva Toteva
Telerik team
answered on 05 Apr 2013, 11:38 AM
Hello Eric, Ryan,

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.

All the best,
Iva Toteva
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Chandra
Top achievements
Rank 1
answered on 29 Aug 2013, 07:27 AM
Hi,
I'm also facing the same problem. except the RTL words it is giving suggestions.
0
Chandra
Top achievements
Rank 1
answered on 29 Aug 2013, 01:44 PM
hi Iva,
 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 

0
Petya
Telerik team
answered on 30 Aug 2013, 11:45 AM
Hello 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
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
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 >>
0
Kushagra
Top achievements
Rank 1
answered on 16 Sep 2013, 06:18 AM
Kindly include the spellchecking for RTL especially for Arabic in Q3 2013 for WPF as we are also facing requests from our customers for getting that included asap.

Regards
Kushagra
0
Petya
Telerik team
answered on 16 Sep 2013, 02:09 PM
Hi 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
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
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 >>
0
Kushagra
Top achievements
Rank 1
answered on 20 Feb 2014, 04:59 AM
Hi Petya,

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
0
Missing User
answered on 24 Feb 2014, 02:38 PM
Hi 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
0
Kushagra
Top achievements
Rank 1
answered on 25 Feb 2014, 10:22 AM
Hi Yancho,

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
0
Kushagra
Top achievements
Rank 1
answered on 25 Feb 2014, 10:25 AM
Can you attach a working sample of this implementation as our customers are eagerly waiting for this feature to come.

Regards,
Kushagra
0
Missing User
answered on 26 Feb 2014, 08:57 AM
Hi 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
0
Kushagra
Top achievements
Rank 1
answered on 26 Feb 2014, 10:15 AM
Thanks Yancho,


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
0
Missing User
answered on 27 Feb 2014, 02:41 PM
Hi 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
0
Kushagra
Top achievements
Rank 1
answered on 02 Mar 2014, 10:33 AM
Hi Yancho,

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
0
Missing User
answered on 05 Mar 2014, 05:21 PM
Hi 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!

Tags
RichTextBox
Asked by
Ryan
Top achievements
Rank 1
Answers by
Iva Toteva
Telerik team
Ryan
Top achievements
Rank 1
Eric
Top achievements
Rank 1
Chandra
Top achievements
Rank 1
Petya
Telerik team
Kushagra
Top achievements
Rank 1
Missing User
Share this question
or