use of com.inet.jortho.FileUserDictionary in project freeplane by freeplane.
the class SpellCheckerController method registerDictionaries.
private void registerDictionaries(final File orthoDir) {
if (!orthoDir.isDirectory())
return;
final String[] dictionaryList = orthoDir.list(new FilenameFilter() {
public boolean accept(final File dir, final String name) {
return name.length() == "dictionary_XX.ortho".length() && name.startsWith("dictionary_") && name.endsWith(".ortho");
}
});
if (dictionaryList.length == 0) {
return;
}
final ResourceController resourceController = ResourceController.getResourceController();
SpellChecker.setUserDictionaryProvider(new FileUserDictionary(resourceController.getFreeplaneUserDirectory()));
final StringBuilder availableLocales = new StringBuilder();
for (int i = 0; i < dictionaryList.length; i++) {
final String language = dictionaryList[i].substring("dictionary_".length(), "dictionary_".length() + 2);
availableLocales.append(language);
availableLocales.append(",");
}
try {
SpellChecker.registerDictionaries(orthoDir.toURI().toURL(), availableLocales.toString(), null, ".ortho");
spellCheckerEnabled = true;
} catch (final MalformedURLException e) {
LogUtils.severe(e);
}
}
Aggregations