diff --git a/local/modules/Tinymce/Smarty/TinyMCELanguage.php b/local/modules/Tinymce/Smarty/TinyMCELanguage.php new file mode 100644 index 000000000..9f108d7fa --- /dev/null +++ b/local/modules/Tinymce/Smarty/TinyMCELanguage.php @@ -0,0 +1,65 @@ +locale = $request->getSession()->getLang()->getLocale(); + } + + public function guessTinyMCELanguage($params, \Smarty_Internal_Template $template) + { + // Find TinyMCE available languages + $finder = new Finder(); + + $files = $finder->in(__DIR__.DS."..".DS."Resources".DS.'js'.DS.'tinymce'.DS.'langs')->sortByName(); + + $miniLocale = substr($this->locale, 0, 2); + + // Find the best matching language + /** @var SplFileInfo $file */ + foreach($files as $file) { + $lang = str_replace('.js', '', $file->getFilename()); + + if ($lang == $this->locale || $lang == $miniLocale) { + return $lang; + } + } + + return ''; + } + + /** + * Define the various smarty plugins hendled by this class + * + * @return array an array of smarty plugin descriptors + */ + public function getPluginDescriptors() + { + return array( + new SmartyPluginDescriptor('function', 'tinymce_lang', $this, 'guessTinyMCELanguage'), + ); + } +} \ No newline at end of file