diff --git a/code/CMSMain.php b/code/CMSMain.php index 6830ad53..2bfce7c8 100644 --- a/code/CMSMain.php +++ b/code/CMSMain.php @@ -81,13 +81,24 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr public function init() { parent::init(); + + // collect languages for TinyMCE spellchecker plugin + if(Translatable::is_enabled()) { + $spellcheckLangs = i18n::get_existing_content_languages(); + } else { + $defaultLang = Translatable::get_default_lang(); + $spellcheckLangs = array($defaultLang => i18n::get_language_name($defaultLang)); + } + $spellcheckSpec = array(); + foreach($spellcheckLangs as $lang => $title) $spellcheckSpec[] = "{$title}={$lang}"; // We don't want this showing up in every ajax-response, it should always be present in a CMS-environment if(!Director::is_ajax()) { Requirements::javascriptTemplate(CMS_DIR . "/javascript/tinymce.template.js", array( "ContentCSS" => (SSViewer::current_theme() ? THEMES_DIR . "/" . SSViewer::current_theme() : project()) . "/css/editor.css", "BaseURL" => Director::absoluteBaseURL(), - "Lang" => i18n::get_tinymce_lang() + "Lang" => i18n::get_tinymce_lang(), + 'SpellcheckLangs' => '+' . implode(',', $spellcheckSpec) )); } diff --git a/javascript/tinymce.template.js b/javascript/tinymce.template.js index a9d76ddf..2fe84579 100755 --- a/javascript/tinymce.template.js +++ b/javascript/tinymce.template.js @@ -30,7 +30,7 @@ if((typeof tinyMCE != 'undefined')) { theme_advanced_buttons1 : "bold,italic,underline,strikethrough,separator,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,separator,bullist,numlist,outdent,indent,hr,charmap", theme_advanced_buttons2 : "undo,redo,separator,cut,copy,paste,pastetext,pasteword,spellchecker,separator,ssimage,ssflash,sslink,unlink,anchor,separator,template,code,separator,search,replace,selectall,visualaid,separator,tablecontrols", theme_advanced_buttons3 : "", - spellchecker_languages : "+English=en", + spellchecker_languages : "$SpellcheckLangs", template_templates : [ { title : "Three column", src : "assets/snippet.html", description : "A simple 3 column layout"},