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

Multi language support

7 Answers 108 Views
SpellChecker
This is a migrated thread and some comments may be shown as answers.
Todd Millett
Top achievements
Rank 1
Todd Millett asked on 12 Apr 2011, 06:48 AM
How can i test multi language support for radspellchecker control?

7 Answers, 1 is accepted

Sort by
0
Andrew
Telerik team
answered on 12 Apr 2011, 10:37 AM
Hello Todd Millett,

RadSpellChecker holds an instance of ISpellChecker for each type of control it supports. So here is the code to get that instance:

IControlSpellChecker controlSpellchecker = ControlSpellCheckersManager.GetControlSpellChecker(typeof(TextBox)); 
ISpellChecker spellChecker = controlSpellchecker.SpellChecker; 
DocumentSpellChecker documentSpellChecker = (DocumentSpellChecker)spellChecker;
As you can see we have extracted the ISpellChecker instance for the type TextBox and cast it to DocumentSpellChecker. Now you can use DocumentSpellChecker.AddDictionary method to add a dictionary for a specific culture.
Once added you can use it by setting the SpellCheckingCulture property of the corresponding ISpellChecker to the culture you have added.

Another way to achieve the same thing is to create a class deriving from RadDictionary and assign a
WordDictionaryMetadata attribute to it, so it can be loaded through MEF.(Don't forget to specify a culture to the constructor of this attribute like [WordDictionaryMetadata("es-ES")] for example ) Then you just specify the DocumentSpellChecker.SpellCheckingCulture property and you are good to go.

We are writing the documentation right now, so we are sorry if we caused any inconvenience by not providing it earlier. Do not hesitate to contact us again if needed.

Greetings,
Andrew
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Todd Millett
Top achievements
Rank 1
answered on 12 Apr 2011, 11:50 AM
I was able to add a different language by using the second option of creating a different assembly, but not with the first option. Using the first option it still loads the en-US language. Can you provide me with a sample regarding the same?
0
Todd Millett
Top achievements
Rank 1
answered on 12 Apr 2011, 11:50 AM
I am pasting the code to make it more clear. :
 
private static void RegisterSpellChecker(IControlSpellChecker controlSpellChecker)
        {
            ISpellChecker ispellChecker = controlSpellChecker.SpellChecker;
            DocumentSpellChecker documentSpellChecker = (DocumentSpellChecker) ispellChecker;
            
            if (documentSpellChecker != null)
            {   
                //documentSpellChecker.AddDictionary(new RadEn_USDictionary(), CultureInfo.InvariantCulture);
                //documentSpellChecker.AddDictionary(new Radde_DEDictionary(), new CultureInfo("de-DE"));
            }
            RadDictionary raddic = new RadDictionary();
            Stream tdfFileStream = Application.GetResourceStream(new Uri("de-DE.tdf", UriKind.Relative)).Stream;
            raddic.Load(tdfFileStream);
            CultureInfo info = new CultureInfo("de-DE");
            documentSpellChecker.AddDictionary(raddic, info);
            ispellChecker.SpellCheckingCulture = info;
            ControlSpellCheckersManager.RegisterControlSpellChecker(controlSpellChecker);
        }
0
Todd Millett
Top achievements
Rank 1
answered on 12 Apr 2011, 12:44 PM
I got it working by modifing the code to  : 

RadDictionary raddic = new RadDictionary();
            Uri uri = new Uri("RadControlsSilverlightApp2;component/de-DE.tdf", UriKind.RelativeOrAbsolute);
            Stream tdfFileStream = Application.GetResourceStream(uri).Stream;
            raddic.Load(tdfFileStream);
            CultureInfo info = new CultureInfo("de-DE");
            documentSpellChecker.AddDictionary(raddic, info);
            //ispellChecker.SpellCheckingCulture = info;
            documentSpellChecker.SpellCheckingCulture = info;
            ControlSpellCheckersManager.RegisterControlSpellChecker(controlSpellChecker);
0
Andrew
Telerik team
answered on 13 Apr 2011, 08:33 AM
Hi Todd Millett,

Thank you for using RadSpellChecker for Silverlight. We are very happy you solved your problem.
If you happen to have other difficulties, contact us immediately.

All the best,
Andrew
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Todd Millett
Top achievements
Rank 1
answered on 13 Apr 2011, 12:29 PM
Thats strange, I thought i had solved the problem, but it still remains. Actually the new language dll was included in the project so it was able to load that dictionary. For reference i have attached the project. Please find below the code for your reference : 
public partial class MainPage : UserControl
    {   
        public MainPage()
        {
            InitializeComponent();
            ExamplesSpellCheckersManager.RegisterSpellCheckers();
        }
...
}

public static class ExamplesSpellCheckersManager
    {
        private static bool registered;


        /// <summary>
        /// This method is used only to work around limitations for using MEF in examples.
        /// </summary>
        public static void RegisterSpellCheckers()
        {
            if (!registered)
            {                
                RegisterSpellChecker(ControlSpellCheckersManager.GetControlSpellChecker(typeof(TextBox)));
                registered = true;
            }
        }
        private static void RegisterSpellChecker(IControlSpellChecker controlSpellChecker)
        {
            ISpellChecker ispellChecker = controlSpellChecker.SpellChecker;
            DocumentSpellChecker documentSpellChecker = (DocumentSpellChecker) ispellChecker;            
            
            RadDictionary raddic = new RadDictionary();
            Uri uri = new Uri("RadControlsSilverlightApp2;component/de-DE.tdf", UriKind.RelativeOrAbsolute);
            Stream tdfFileStream = Application.GetResourceStream(uri).Stream;
            raddic.Load(tdfFileStream);
            
            CultureInfo info = new CultureInfo("de-DE");
            documentSpellChecker.AddDictionary(raddic, info);
            documentSpellChecker.SpellCheckingCulture = info;
            ControlSpellCheckersManager.RegisterControlSpellChecker(controlSpellChecker);
        }
    }
0
Andrew
Telerik team
answered on 15 Apr 2011, 08:13 AM
Hi Todd Millett,

As far as I see your problem is that the English dictionary is always loaded, no matter what culture you have set to the SpellCheckingCulture property. However I copied your code and pasted it in a blank project and found no problems. I am attaching a demo project with my work. Please review it and get back to us, if you still have problems.

Greetings,
Andrew
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
SpellChecker
Asked by
Todd Millett
Top achievements
Rank 1
Answers by
Andrew
Telerik team
Todd Millett
Top achievements
Rank 1
Share this question
or