|
@@ -2976,16 +2976,21 @@ function spell_init()
|
|
|
{
|
|
|
global $context, $txt;
|
|
|
|
|
|
+
|
|
|
+ $context['spell_utf8'] = ($txt['lang_character_set'] == 'UTF-8');
|
|
|
+ $lang_locale = str_replace('.utf8', '', $txt['lang_locale']);
|
|
|
+
|
|
|
|
|
|
- if (function_exists('enchant_broker_init'))
|
|
|
+
|
|
|
+ if (function_exists('enchant_broker_init') && ($context['spell_utf8'] || function_exists('iconv')))
|
|
|
{
|
|
|
|
|
|
$context['enchant_broker'] = enchant_broker_init();
|
|
|
|
|
|
|
|
|
- if (!empty($txt['lang_locale']) && enchant_broker_dict_exists($context['enchant_broker'], $txt['lang_locale']))
|
|
|
- {
|
|
|
- $enchant_link = enchant_broker_request_dict($context['enchant_broker'], $txt['lang_locale']);
|
|
|
+ if (!empty($lang_locale) && enchant_broker_dict_exists($context['enchant_broker'], $lang_locale))
|
|
|
+ {
|
|
|
+ $enchant_link = enchant_broker_request_dict($context['enchant_broker'], $lang_locale);
|
|
|
}
|
|
|
elseif (enchant_broker_dict_exists($context['enchant_broker'], $txt['lang_dictionary']))
|
|
|
{
|
|
@@ -3048,11 +3053,17 @@ function spell_init()
|
|
|
*/
|
|
|
function spell_check($dict, $word)
|
|
|
{
|
|
|
- global $context;
|
|
|
+ global $context, $txt;
|
|
|
|
|
|
|
|
|
if ($context['provider'] == 'enchant')
|
|
|
{
|
|
|
+
|
|
|
+ if (!$context['spell_utf8'])
|
|
|
+ {
|
|
|
+
|
|
|
+ $word = iconv($txt['lang_charset'], 'UTF-8', $word);
|
|
|
+ }
|
|
|
return enchant_dict_check($dict, $word);
|
|
|
}
|
|
|
elseif ($context['provider'] == 'pspell')
|
|
@@ -3072,11 +3083,30 @@ function spell_check($dict, $word)
|
|
|
*/
|
|
|
function spell_suggest($dict, $word)
|
|
|
{
|
|
|
- global $context;
|
|
|
+ global $context, $txt;
|
|
|
|
|
|
if ($context['provider'] == 'enchant')
|
|
|
{
|
|
|
- return enchant_dict_suggest($dict, $word);
|
|
|
+
|
|
|
+ if (!$context['spell_utf8'])
|
|
|
+ {
|
|
|
+
|
|
|
+ $word = iconv($txt['lang_charset'], 'UTF-8', $word);
|
|
|
+ $suggestions = enchant_dict_suggest($dict, $word);
|
|
|
+
|
|
|
+
|
|
|
+ foreach($suggestions as $index => $suggestion)
|
|
|
+ {
|
|
|
+
|
|
|
+ $suggestions[$index] = iconv('UTF-8', $txt['lang_charset'] . '//TRANSLIT', $suggestion);
|
|
|
+ }
|
|
|
+
|
|
|
+ return $suggestions;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return enchant_dict_suggest($dict, $word);
|
|
|
+ }
|
|
|
}
|
|
|
elseif ($context['provider'] == 'pspell')
|
|
|
{
|