Home Reference Source Test Repository
public class | source

DictionarySync

DictioanrySync handles downloading and saving Hunspell dictionaries. Pass it to {{SpellCheckHandler}} to configure a custom cache directory.

Static Method Summary

Static Public Methods
public static

Override the default logger for this class.

Constructor Summary

Public Constructor
public

constructor(cacheDir: String)

Creates a DictionarySync

Member Summary

Public Members
public

Method Summary

Public Methods
public

loadDictionaryForLanguage(langCode: String, cacheOnly: Boolean): Buffer | String

Loads the dictionary for a given language code, trying first to load a local version, then downloading it.

public

Pre-download dictionaries for languages that the user is likely to speak (based usually on their keyboard layouts).

Static Public Methods

public static setLogger(fn: Function) source

Override the default logger for this class. You probably want to use {{setGlobalLogger}} instead

Params:

NameTypeAttributeDescription
fn Function

The function which will operate like console.log

Public Constructors

public constructor(cacheDir: String) source

Creates a DictionarySync

Params:

NameTypeAttributeDescription
cacheDir String

The path to a directory to store dictionaries. If not given, the Electron user data directory will be used.

Public Members

public cacheDir: * source

Public Methods

public loadDictionaryForLanguage(langCode: String, cacheOnly: Boolean): Buffer | String source

Loads the dictionary for a given language code, trying first to load a local version, then downloading it. You probably don't want this method directly, but the wrapped version {{loadDictionaryForLanguageWithAlternatives}} which is in {{SpellCheckHandler}}.

Params:

NameTypeAttributeDescription
langCode String

The language code (i.e. 'en-US')

cacheOnly Boolean

If true, don't load the file content into memory, only download it

Return:

Buffer | String

A Buffer of the file contents if {{cacheOnly}} is False, or the path to the file if True.

public preloadDictionaries(languageList: Array<String>): Array<String> source

Pre-download dictionaries for languages that the user is likely to speak (based usually on their keyboard layouts). Note that this method only works on Windows currently.

Params:

NameTypeAttributeDescription
languageList Array<String>

Override the list of languages to download, for testing.

Return:

Array<String>

A list of strings to dictionaries that were downloaded.