Spellchecking for Arabic

21 posts, 1 answers
  1. Ryan
    Ryan avatar
    7 posts
    Member since:
    Sep 2012

    Posted 28 Mar 2013 Link to this post

    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.
  2. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 01 Apr 2013 Link to this post

    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.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Ryan
    Ryan avatar
    7 posts
    Member since:
    Sep 2012

    Posted 01 Apr 2013 Link to this post

    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
  5. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 02 Apr 2013 Link to this post

    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.

  6. Eric
    Eric avatar
    1 posts
    Member since:
    Apr 2013

    Posted 02 Apr 2013 Link to this post

    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?
  7. Ryan
    Ryan avatar
    7 posts
    Member since:
    Sep 2012

    Posted 03 Apr 2013 Link to this post

    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.
  8. Answer
    Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 05 Apr 2013 Link to this post

    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.

  9. Chandra
    Chandra avatar
    3 posts
    Member since:
    Mar 2013

    Posted 29 Aug 2013 Link to this post

    Hi,
    I'm also facing the same problem. except the RTL words it is giving suggestions.
  10. Chandra
    Chandra avatar
    3 posts
    Member since:
    Mar 2013

    Posted 29 Aug 2013 Link to this post

    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 

  11. Petya
    Admin
    Petya avatar
    975 posts

    Posted 30 Aug 2013 Link to this post

    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 >>
  12. Kushagra
    Kushagra avatar
    16 posts
    Member since:
    May 2011

    Posted 16 Sep 2013 Link to this post

    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
  13. Petya
    Admin
    Petya avatar
    975 posts

    Posted 16 Sep 2013 Link to this post

    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 >>
  14. Kushagra
    Kushagra avatar
    16 posts
    Member since:
    May 2011

    Posted 19 Feb 2014 in reply to Petya Link to this post

    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
  15. Yancho
    Admin
    Yancho avatar
    72 posts

    Posted 24 Feb 2014 Link to this post

    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
  16. Kushagra
    Kushagra avatar
    16 posts
    Member since:
    May 2011

    Posted 25 Feb 2014 in reply to Yancho Link to this post

    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
  17. Kushagra
    Kushagra avatar
    16 posts
    Member since:
    May 2011

    Posted 25 Feb 2014 in reply to Kushagra Link to this post

    Can you attach a working sample of this implementation as our customers are eagerly waiting for this feature to come.

    Regards,
    Kushagra
  18. Yancho
    Admin
    Yancho avatar
    72 posts

    Posted 26 Feb 2014 Link to this post

    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
  19. Kushagra
    Kushagra avatar
    16 posts
    Member since:
    May 2011

    Posted 26 Feb 2014 in reply to Yancho Link to this post

    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
  20. Yancho
    Admin
    Yancho avatar
    72 posts

    Posted 27 Feb 2014 Link to this post

    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
  21. Kushagra
    Kushagra avatar
    16 posts
    Member since:
    May 2011

    Posted 02 Mar 2014 in reply to Yancho Link to this post

    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
  22. Yancho
    Admin
    Yancho avatar
    72 posts

    Posted 05 Mar 2014 Link to this post

    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!

Back to Top
UI for WPF is Visual Studio 2017 Ready