Set defaults for 'spellcheck_languages' and make sure the user language is set correctly

release-0.6
thomascube 17 years ago
parent d14a57d006
commit 326f3d9130

@ -376,8 +376,8 @@ function rcmail_compose_body($attrib)
$body = rcmail_create_draft_body($body, $isHtml); $body = rcmail_create_draft_body($body, $isHtml);
} }
$tinylang = substr($_SESSION['language'], 0, 2); $lang = $tinylang = strtolower(substr($_SESSION['language'], 0, 2));
if (!file_exists('program/js/tiny_mce/langs/'.$tinylang.'.js')) if (!file_exists(INSTALL_PATH . 'program/js/tiny_mce/langs/'.$tinylang.'.js'))
$tinylang = 'en'; $tinylang = 'en';
$OUTPUT->include_script('tiny_mce/tiny_mce.js'); $OUTPUT->include_script('tiny_mce/tiny_mce.js');
@ -403,11 +403,13 @@ function rcmail_compose_body($attrib)
// include GoogieSpell // include GoogieSpell
if (!empty($CONFIG['enable_spellcheck'])) { if (!empty($CONFIG['enable_spellcheck'])) {
$googie_lang_set = $editor_lang_set = ''; $spellcheck_langs = (array)$RCMAIL->config->get('spellcheck_languages', array('da'=>'Dansk', 'de'=>'Deutsch', 'en' => 'English', 'es'=>'Español', 'fr'=>'Français', 'it'=>'Italiano', 'nl'=>'Nederlands', 'pl'=>'Polski', 'pt'=>'Português', 'fi'=>'Suomi', 'sv'=>'Svenska'));
if (!empty($CONFIG['spellcheck_languages']) && is_array($CONFIG['spellcheck_languages'])) { if (!$spellcheck_langs[$lang])
$googie_lang_set = "googie.setLanguages(".json_serialize($CONFIG['spellcheck_languages']).");\n"; $lang = 'en';
foreach ($CONFIG['spellcheck_languages'] as $key => $name)
$editor_lang_set .= ($editor_lang_set ? ',' : '') . ($key == $tinylang ? '+' : '') . JQ($name).'='.JQ($key); $editor_lang_set = array();
foreach ($spellcheck_langs as $key => $name) {
$editor_lang_set[] = ($key == $lang ? '+' : '') . JQ($name).'='.JQ($key);
} }
$OUTPUT->include_script('googiespell.js'); $OUTPUT->include_script('googiespell.js');
@ -417,7 +419,8 @@ function rcmail_compose_body($attrib)
"googie.lang_rsm_edt = \"%s\";\n". "googie.lang_rsm_edt = \"%s\";\n".
"googie.lang_close = \"%s\";\n". "googie.lang_close = \"%s\";\n".
"googie.lang_revert = \"%s\";\n". "googie.lang_revert = \"%s\";\n".
"googie.lang_no_error_found = \"%s\";\n%s". "googie.lang_no_error_found = \"%s\";\n".
"googie.setLanguages(%s);\n".
"googie.setCurrentLanguage('%s');\n". "googie.setCurrentLanguage('%s');\n".
"googie.decorateTextarea('%s');\n". "googie.decorateTextarea('%s');\n".
"%s.set_env('spellcheck', googie);", "%s.set_env('spellcheck', googie);",
@ -427,13 +430,13 @@ function rcmail_compose_body($attrib)
JQ(Q(rcube_label('close'))), JQ(Q(rcube_label('close'))),
JQ(Q(rcube_label('revertto'))), JQ(Q(rcube_label('revertto'))),
JQ(Q(rcube_label('nospellerrors'))), JQ(Q(rcube_label('nospellerrors'))),
$googie_lang_set, json_serialize($spellcheck_langs),
substr($_SESSION['language'], 0, 2), $lang,
$attrib['id'], $attrib['id'],
JS_OBJECT_NAME), 'foot'); JS_OBJECT_NAME), 'foot');
rcube_add_label('checking'); rcube_add_label('checking');
$OUTPUT->set_env('spellcheck_langs', $editor_lang_set); $OUTPUT->set_env('spellcheck_langs', join(',', $editor_lang_set));
} }
$out .= "\n".'<iframe name="savetarget" src="program/blank.gif" style="width:0;height:0;border:none;visibility:hidden;"></iframe>'; $out .= "\n".'<iframe name="savetarget" src="program/blank.gif" style="width:0;height:0;border:none;visibility:hidden;"></iframe>';

Loading…
Cancel
Save