@@ -18,8 +18,8 @@ const DEFAULT_LOCALE = 'en-us';
1818async function loadDictionary ( locale ) {
1919 try {
2020 const fileLocation = path . join ( DICTIONARY_PATH , `hunspell-dict-${ locale } /${ locale } ` ) ;
21- await provider . loadDictionary ( locale , readFileSync ( `${ fileLocation } .dic` ) , readFileSync ( `${ fileLocation } .aff` ) ) ;
2221 debug ( 'Loaded dictionary' , locale , 'from' , fileLocation ) ;
22+ return provider . loadDictionary ( locale , readFileSync ( `${ fileLocation } .dic` ) , readFileSync ( `${ fileLocation } .aff` ) ) ;
2323 } catch ( err ) {
2424 console . error ( 'Could not load dictionary' , err ) ;
2525 }
@@ -44,8 +44,8 @@ export async function switchDict(locale = DEFAULT_LOCALE) {
4444 if ( currentDict ) {
4545 provider . unloadDictionary ( locale ) ;
4646 }
47- loadDictionary ( locale ) ;
48- attached . switchLanguage ( locale ) ;
47+ await loadDictionary ( locale ) ;
48+ await attached . switchLanguage ( locale ) ;
4949
5050 debug ( 'Switched dictionary to' , locale ) ;
5151
@@ -77,9 +77,11 @@ export default async function initialize(languageCode = DEFAULT_LOCALE) {
7777 debug ( 'Attaching spellcheck provider' ) ;
7878 attached = await attachSpellCheckProvider ( provider ) ;
7979
80- debug ( 'Available spellchecker dictionaries' , provider . availableDictionaries ) ;
80+ const availableDictionaries = await provider . getAvailableDictionaries ( ) ;
8181
82- attached . switchLanguage ( locale ) ;
82+ debug ( 'Available spellchecker dictionaries' , availableDictionaries ) ;
83+
84+ await switchDict ( locale ) ;
8385
8486 return provider ;
8587 } catch ( err ) {
0 commit comments