getSession() != null) { $this->locale = $request->getLocale(); } else { $this->locale = Lang::getDefaultLanguage()->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'), ); } }