Spell checking for multiple languages

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Spell checking for multiple languages

Postby Dimkas » Tue Feb 14, 2017 3:39 am

Hello!

I have one small task - spell checking for several languages.
I read many posts here, googling some information.

Now I can set one lang which will used for spell checking.

Does it possible to do spell checking for several languages simultaneously?
Or, how can I change current lang (--lang arg option) at runtime?
May be another solution?
Dimkas
Newbie
 
Posts: 6
Joined: Fri Feb 03, 2017 6:45 am

Re: Spell checking for multiple languages

Postby amaitland » Tue Feb 14, 2017 6:46 am

You should be able to change spellchecker dictionaries at runtime by calling CefRequestContext::SetPreference see apidocs3/projects/(default)/CefRequestContext.html#SetPreference(constCefString&,CefRefPtr%3CCefValue%3E,CefString&)

Search this forum for some examples.

I've never tried multiple dictionaries, so you'll have to test it out, I'm guessing the relevant preference key is
https://cs.chromium.org/chromium/src/co ... ry%22&l=18
Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1292
Joined: Wed Jan 14, 2015 2:35 am

Re: Spell checking for multiple languages

Postby Dimkas » Tue Feb 14, 2017 2:09 pm

Thanks, works.
I set two languages for spell checking - works well, both.
Dimkas
Newbie
 
Posts: 6
Joined: Fri Feb 03, 2017 6:45 am

Re: Spell checking for multiple languages

Postby mpkfa » Wed Mar 07, 2018 9:57 am

Dimkas wrote:Thanks, works.
I set two languages for spell checking - works well, both.


How exactly did you manage to make it work? And what CEF version are you using?

I did this on initialization...

Code: Select all
private void Browser_IsBrowserInitializedChanged( object sender, IsBrowserInitializedChangedEventArgs e )
        {
            if ( e.IsBrowserInitialized )
            {
                Cef.UIThreadTaskFactory.StartNew( delegate
                {
                    var rc = cwb.GetBrowser().GetHost().RequestContext;
                    string error;
                    var dicts = new List<string>();
                    dicts.Add( "en-US" );
                    dicts.Add( "de-DE" );
                    dicts.Add( "fr-FR" );
                    rc.SetPreference( "browser.enable_spellchecking", true, out error );
                    rc.SetPreference( "spellcheck.dictionaries", dicts, out error );
                    rc.SetPreference( "spellcheck.dictionary", "en-US", out error );
                    rc.SetPreference( "spellcheck.use_spelling_service", true, out error );

                } );
        }
    }


...and then tried to change language the same way...

Code: Select all
Cef.UIThreadTaskFactory.StartNew( delegate
                {
                    var rc = cwb.GetBrowser().GetHost().RequestContext;
                    string error;
                    rc.SetPreference( "spellcheck.dictionary", "de-DE", out error );
                } );



...but to no avail.

What am I doing wrong here?
mpkfa
Newbie
 
Posts: 1
Joined: Wed Mar 07, 2018 9:46 am

Re: Spell checking for multiple languages

Postby ecastillo » Mon Jul 23, 2018 8:54 pm

Please somebody has solve the problem to change the language for spell checking?
ecastillo
Newbie
 
Posts: 1
Joined: Mon Jul 23, 2018 10:15 am

Re: Spell checking for multiple languages

Postby salvadordf » Thu Jul 26, 2018 7:11 am

Enabling the "spellcheck.use_spelling_service" preference doesn't work in CEF and the spell checker will stop working if you enable it.

Just enable "browser.enable_spellchecking" and set the dictionaries in "spellcheck.dictionaries".
Maintainer of the CEF4Delphi, WebView4Delphi, WebUI4Delphi and WebUI4CSharp projects.
User avatar
salvadordf
Expert
 
Posts: 129
Joined: Sun Dec 18, 2016 8:39 am
Location: Spain

Re: Spell checking for multiple languages

Postby angshuman » Thu Jan 17, 2019 7:18 am

Hi,
I get this error when I try to set dictionaries as suggested (in my C#/WPF code) -
Code: Select all
Trying to set a preference of type LIST to value of type NULL


This is what I tried -

Code: Select all
 List<string> spellCheckDictionaries = new List<string> {
                    "en-GB"
                };

                if (!browserRequestContext.SetPreference("spellcheck.dictionaries", spellCheckDictionaries, out error))
                {
                    _log.Error($"Failed to enable spell check on the  browser. Error is {error}");
                }   


But, when I do browserRequestContext.GetAllPreferences(true), I get 26 preferences back, one of which is spellcheck. And, it seems to have the dictionaries key in there.

So, how do I set multiple language specific dictionaries such that it gets set and also download as a .bdic file in the Cache\Dictionaries folder ?
angshuman
Techie
 
Posts: 10
Joined: Thu Jan 17, 2019 6:12 am

Re: Spell checking for multiple languages

Postby MikeH » Thu Mar 28, 2019 11:10 am

I had the same issue. try using:

Code: Select all
List<object> spellCheckDictionaries = new List<string> {
                    "en-GB"
                };
MikeH
Newbie
 
Posts: 2
Joined: Thu Mar 28, 2019 11:07 am

Re: Spell checking for multiple languages

Postby MikeH » Fri Mar 29, 2019 9:58 am

Correction:

Code: Select all
List<object> spellCheckDictionaries = new List<object> {
                    "en-GB"
                };
MikeH
Newbie
 
Posts: 2
Joined: Thu Mar 28, 2019 11:07 am

Re: Spell checking for multiple languages

Postby amaitland » Fri Mar 29, 2019 3:34 pm

If you are using CefSharp then Dictionary<string> should work starting from version 71
Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1292
Joined: Wed Jan 14, 2015 2:35 am


Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 94 guests