From c344b64f13e7aa3c87c423cc14e57536d28c40b6 Mon Sep 17 00:00:00 2001 From: Thomas Bruederli Date: Fri, 18 Oct 2013 12:50:25 +0200 Subject: Get supported spell-check languages from the configured backend; replace suspended google spell service with our new service at spell.roundcube.net --- program/lib/Roundcube/rcube_spellcheck_pspell.php | 29 +++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'program/lib/Roundcube/rcube_spellcheck_pspell.php') diff --git a/program/lib/Roundcube/rcube_spellcheck_pspell.php b/program/lib/Roundcube/rcube_spellcheck_pspell.php index ce089ed8f..b12684e43 100644 --- a/program/lib/Roundcube/rcube_spellcheck_pspell.php +++ b/program/lib/Roundcube/rcube_spellcheck_pspell.php @@ -29,6 +29,35 @@ class rcube_spellcheck_pspell extends rcube_spellcheck_engine private $plink; private $matches = array(); + /** + * Return a list of languages supported by this backend + * + * @see rcube_spellcheck_engine::languages() + */ + function languages() + { + $defaults = array('en'); + $langs = array(); + + // get aspell dictionaries + exec('aspell dump dicts', $dicts); + if (!empty($dicts)) { + $seen = array(); + foreach ($dicts as $lang) { + $lang = preg_replace('/-.*$/', '', $lang); + $langc = strlen($lang) == 2 ? $lang.'_'.strtoupper($lang) : $lang; + if (!$seen[$langc]++) + $langs[] = $lang; + } + $langs = array_unique($langs); + } + else { + $langs = $defaults; + } + + return $langs; + } + /** * Initializes PSpell dictionary */ -- cgit v1.2.3