Dictionary is not being loaded

10 posts, 0 answers
  1. plusHR
    plusHR avatar
    58 posts
    Member since:
    Aug 2012

    Posted 07 Jul 2011 Link to this post

    Hi all, we use the reduce xap option and seen in the forums the following code to register the spell-checker, however the dictionary is still not present, can you advise what is wrong. We are referencing the correct proofing dictionary in the project.


     ControlSpellCheckersManager.RegisterControlSpellChecker(new TextBoxSpellChecker());
                ControlSpellCheckersManager.RegisterControlSpellChecker(new RadRichTextBoxSpellChecker());
                IControlSpellChecker controlSpellchecker = ControlSpellCheckersManager.GetControlSpellChecker(typeof(RadRichTextBox));
                ISpellChecker spellChecker = controlSpellchecker.SpellChecker;
                DocumentSpellChecker documentSpellChecker = (DocumentSpellChecker)spellChecker;
                documentSpellChecker.AddDictionary(new RadEn_USDictionary(), new System.Globalization.CultureInfo("en-US"));

    in the App.xaml.cs in "Application_Startup"

    Thanks
  2. Andrew
    Admin
    Andrew avatar
    140 posts

    Posted 12 Jul 2011 Link to this post

    Hi Paul,

    The code you are using is correct. The problem may be appearing, because your current culture is set to something different from en-US. Thus the spellchecker is not using the dictionary you explicitly have loaded.
    To fix that, add the following line to your code:

    documentSpellChecker.SpellCheckingCulture = new System.Globalization.CultureInfo("en-US");

    If that doesn't help contact us again, so we can investigate further. Best wishes,
    Andrew
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  3. DevCraft banner
  4. plusHR
    plusHR avatar
    58 posts
    Member since:
    Aug 2012

    Posted 13 Jul 2011 Link to this post

    Thanks that sorted it. We have downloaded the en-GB TDF files. If we create a separate assembly to load the TDF does this have to be a standard c# or Silverlight class library. When I try to inherit the RadDictionary it is not found even though I reference the Telerik.Windows.Document.Proofing dll. We also use reduce application xap using library caching so would we need to make any changes to the class. Do you have an example?

    Thanks
    Paul
  5. Andrew
    Admin
    Andrew avatar
    140 posts

    Posted 14 Jul 2011 Link to this post

    Hello Paul,

    We are glad that this solved your problem, in a way. So now, to your next questions. 
    You can create another assembly similar to Telerik.Windows.Documents.Proofing.Dictionaries.En-US which loads dictionary you have chosen. To do that you have to create a Silverlight Class Library project. Add the .tdf file, set its Build Action to Resource and Copy to Output Directory to Copy if newer.
    Now the only thing you have to do is to create a class which inherits from RadDictionary, which in turn implements a method that loads the .tdf file. The following code shows how to achieve that for a German dictionary.

    [WordDictionaryMetadata("de-DE")]
        public class RadDe-DEDictionary : RadDictionary
        {
            public RadDe-DEDictionary()
            {
            }
     
            protected override void EnsureDictionaryLoadedOverride()
            {
                Stream stream = Application.GetResourceStream(new Uri("RadDe;component/de-DE.tdf", UriKind.Relative)).Stream;
                this.Load(stream);
            }
        }
    Thus you are ready with the creation of the assembly.

    For the MEF to be able to discover this assembly you need to do one more thing. You should add the following line to the Application_Startup eventhandler.
    RadCompositionInitializer.Container = new CompositionContainer(new SafeXapCatalog());

    Now you are good to go. When you add a reference to that assembly in your project and set the SpellCheckingCulture to "de-DE" for example, this .tdf file will be used for spellchecking.

    Some side notes:
    1. RadDictionary resides in Telerik.Windows.Documents assembly in Telerik.Windows.Documents.Proofing namespace.
    2. To use the WordDictionaryMetadata attribute in your Silverlight Class Library project you have to add a reference to System.ComponentModel.Composition

    If this doesn't help you, contact us again. Best wishes,
    Andrew
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  6. plusHR
    plusHR avatar
    58 posts
    Member since:
    Aug 2012

    Posted 14 Jul 2011 Link to this post

    Thanks, however I cannot find where the following is located;

    RadCompositionInitializer.Container = new CompositionContainer(new SafeXapCatalog());

    Regards
    Paul

  7. plusHR
    plusHR avatar
    58 posts
    Member since:
    Aug 2012

    Posted 14 Jul 2011 Link to this post

    Sorted it, I didn't need that line. I signed the assembly and created an extmap.xml file and reference it from the main application and it works nicely. Thanks Paul
  8. Tarun
    Tarun avatar
    32 posts
    Member since:
    Apr 2011

    Posted 24 Aug 2011 Link to this post

    Hi,

    How do i avoid writing anything in the  Application_Startup eventhandler.

    My scenario is such that, i have created custom controls in a library. And, i have implemented the IControlSpellChecker interface.

    Also, added the different .tdf files to the same library (as suggested).

    Now, how do i use the CustomDictioanries (from the same assembly)?

    I dont want to write the RadCompositionInitializer in every SilverLight application that i create. Is it possible to refernce it from within the custom controls dll.

    Paul,
    Can you please tell how did u achieve this ?
  9. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 29 Aug 2011 Link to this post

    Hello Tarun,

    In that case, you can add the line from Paul's snippet in the constructor of your custom control, just before the InitializeComponent invocation like this:

    public SpellCheckingControl()
    {
        RadCompositionInitializer.Container = new CompositionContainer(new SafeXapCatalog());
        InitializeComponent();
    }
    All the best,
    Iva
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

  10. Tarun
    Tarun avatar
    32 posts
    Member since:
    Apr 2011

    Posted 08 Sep 2011 Link to this post

    Hi Andrew,

    Referring to your response (Posted on Jul 14, 2011), i did exactly the same things.

    - Created a Silverlight Class Library project.
    - Added .tdf files to that (set the Build action and the Copy to output Directory).
    - Created class inheriting from RadDictionary.
    - Added the WordDictionaryMetadata attribute with proper Culture.
    - Added the CompositionInitializer line.
    - And finally, set the SpellCheckingCulture.

    But, when i dynamically change the SpellCheckingCulture, i dont see the respective dictionaries getting loaded.

    Everytime, the spellchecker is using the default english language.
    I have tried to get the spellCheckingCulture just before calling the RadSpellChecker.Check() method also. It says the SpellCheckingCulture is set to whatever i set to. But still, it is not able to load the respective dictionary.

    Am i missing something ?

    One more point:
    If, instead of setting the spell checking culture, i set the Thread.CurrentThread.CurrentUICulture, then in that case, it is loading the respective dictionary.

    Isn't it possible to set the language (for dictionary to use) only for SpellChecker (as in asp.net spellCheck) ??

    Please respond asap.

    Thanks



  11. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 08 Sep 2011 Link to this post

    Hi Tarun,

    The localization language is independent from the spell-checking language.
    There is a demo and further explanations of how RadSpellChecker can be used with different languages and how they can be changed runtime here.
    More information on localizing RadControls for Silverlight can be found in our online documentation. The list of all strings that RadSpellChecker uses has been published in this forum post.
    If you are experiencing any difficulties, we would appreciate some more details or a sample project illustrating the issue.

    Regards,
    Iva
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Back to Top
DevCraft banner