Multi language support

8 posts, 0 answers
  1. Todd Millett
    Todd Millett avatar
    115 posts
    Member since:
    Jul 2009

    Posted 12 Apr 2011 Link to this post

    How can i test multi language support for radspellchecker control?
  2. Andrew
    Admin
    Andrew avatar
    140 posts

    Posted 12 Apr 2011 Link to this post

    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
  3. DevCraft banner
  4. Todd Millett
    Todd Millett avatar
    115 posts
    Member since:
    Jul 2009

    Posted 12 Apr 2011 Link to this post

    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?
  5. Todd Millett
    Todd Millett avatar
    115 posts
    Member since:
    Jul 2009

    Posted 12 Apr 2011 Link to this post

    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);
            }
  6. Todd Millett
    Todd Millett avatar
    115 posts
    Member since:
    Jul 2009

    Posted 12 Apr 2011 Link to this post

    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);
  7. Andrew
    Admin
    Andrew avatar
    140 posts

    Posted 13 Apr 2011 Link to this post

    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
  8. Todd Millett
    Todd Millett avatar
    115 posts
    Member since:
    Jul 2009

    Posted 13 Apr 2011 Link to this post

    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);
            }
        }
  9. Andrew
    Admin
    Andrew avatar
    140 posts

    Posted 15 Apr 2011 Link to this post

    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
Back to Top
DevCraft banner