Spellchecking with spelling pane and custom dictionaries in extension class
We use the extensionclass of SfRichtextboxAdv
<this:SfRichTextBoxAdvExtension x:Name="rtfText" Text="{Binding Path=RtfText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" LayoutType="Continuous" EnableMiniToolBar="False" Margin="0,2,0,0" Language="de" HorizontalAlignment="Stretch">
<this:SfRichTextBoxAdvExtension.SpellChecker>
<syncfusion:SpellChecker IsEnabled="True"/>
</this:SfRichTextBoxAdvExtension.SpellChecker>
</this:SfRichTextBoxAdvExtension>
We defined a custom dictionary in the code behind:
rtfText.SpellChecker.CustomDictionaries.Add(@"Dictionaries\Sample.txt");
When using the spell checking with the spell pane it shows a unknown word and the user clicks "add to dictionary". We can see the word in the dictionary file and it isn't marked as wrong in the texta anymore, but only until we restart the application. After restarting it the word is again marked as wrong.
Also if we add a word manually into the custom dictionary file, it is marked as wrong in the text and also the spell check pane.
Please find attached a sample.
Thanks in advance!
Best Regards,
Elke
Attachment: Test_f1177c6e.zip
Elke, when checking spell check based on a custom
dictionary, the custom dictionary file should be in the following format Custom_DictionaryName_LangageID.dic
As you are using the German language, please name the custom dictionary as Custom_MyDictionary_de_DE.dic
So, the words added using the 'add to dictionary' feature and those added
manually in the custom dictionary will be ignored during spellchecking in the
SfRichTextBoxAdv.
Hi,
I still have problems with the custom dictionary. Even if I rename the file I can add new words with the spelling pane add button and it is written to the file like before, but the next time I start the application the word isn't recognized anymore. I changed my sample code and attached it. What else am I doing wrong?
Thanks in advance!
Elke
Attachment: Test_d5654b8.zip
Elke, from your code, we noticed that you have only enabled spell-checking
for the SfRichTextBoxAdv control and used a custom dictionary. However, when
spell checking is enabled alone in the SfRichTextBoxAdv, it defaults to using
Microsoft's built-in spell checker. Therefore, the words you've defined in the
custom dictionary are not recognized for spell-checking.
If you intend to use the custom dictionary for spell checking, please set the
property 'UseFrameworkSpellCheck'
to false. This ensures that the SfRichTextBoxAdv utilizes the
custom dictionary for spell checking. Additionally, words added to the custom
dictionary will be ignored during spell checking in the SfRichTextBoxAdv, even
when the application is restarted.
|
<this:SfRichTextBoxAdvExtension.SpellChecker> <syncfusion:SpellChecker IsEnabled="True" UseFrameworkSpellCheck="False"/> </this:SfRichTextBoxAdvExtension.SpellChecker> </this:SfRichTextBoxAdvExtension> |
Thanks! Now the CustomDictionary works!
I can't use FrameWorkSpellCheck together with custom dictionaries, so if I want the user to be able to add own words to the spellchecking, I need to add my own dictionary. did I get this right?
Is it possible to add a hunspell dictionary? The dictionary collection is a List of strings, so I can only add a filename of a dic file but not a hunspell dictionary with a additional grammar file. I find an example for adding a hunspell dictionary to the SfSpellChecker but the spellchecker in the RichtextboxAdv seems to be different. Where can I find more detailed information about the RichtextbixAdv Spellchecker, the online documentation is very short.
Thanks in advance!
Elke
Elke, the property "UseFrameworkSpellCheck"
is set to use the Microsoft built-in spell checker, which is supported only when
WPF provides a default dictionary. These dictionaries are available for
English, French, German, and Spanish languages. However, you cannot add your
own words for spellchecking using this built-in spell checker.
If you want users to be able to add their own words for spell-checking, you
need to add your dictionary to the custom dictionary and Yes, that's correct. We cannot use the "UseFrameworkSpellCheck" property and custom dictionary together.
As of now, SfRichTextBoxAdv does not support spell checking using the Hunspell
dictionary. However, we have provided support for spell checking using the default
framework dictionary, custom dictionary, and Dictionary. We have already provided the required information about spell-checking in the
UG documentation. Please refer to it for further guidance.
https://help.syncfusion.com/wpf/richtextbox/spell-check
Thanks for your answer!
I've already seen the documentary you suggested, but it's very short. Do you have an example of how to add a dictionary and a custom dictionary? It doesn't use my dictionary for spellchecking when I add both, it only ever uses the CustomDictionary.
Thanks in advance.
Elke, we can define both a dictionary and a custom
dictionary for spell-checking in SfRichTextBoxAdv.
The dictionary file should be named in the following format: LanguageID.dic.
Since you're using the German language, please name the dictionary file de_DE.dic.
For the custom dictionary, the file should be named in the following format:
Custom_DictionaryName_LanguageID.dic. For your case, please name
the custom dictionary file
Custom_MyDictionary_de_DE.dic.
Note that the "add to dictionary" feature is supported only in the
custom dictionary, where words can be added to it. This feature is not
supported in the dictionary.
Thanks! It works after renaming my dictionary to "de_DE.dic" (it was "[CompanyName]_de_DE.dic").
Elke, Happy to hear the issue is resolved. You're most welcome.
- 9 Replies
- 2 Participants
- Marked answer
-
EG Elke Goellinger
- Jan 17, 2024 12:29 PM UTC
- Feb 20, 2024 10:38 AM UTC