/** * Get the instance of CompojoomJLanguage * * @param string $lang The language * @param bool $debug Debug * * @return CompojoomJLanguage */ public static function getInstance($lang, $debug = false) { if (!self::$instance) { self::$instance = new CompojoomJLanguage($lang, $debug); } return self::$instance; }
/** * Loads a language file to Joomla.JText_() * * @param string $extension The extension language file * @param string $path The path to the file (JPATH_COMPONENT) * * @return void */ public static function loadJavaScriptLanguage($extension, $path) { require_once __DIR__ . '/CompojoomJLanguage.php'; $clang = CompojoomJLanguage::getInstance(JFactory::getApplication()->get('config.language')); $strings = $clang->getStrings(); $lang = JFactory::getLanguage(); $clang->load($extension, $path, null, false, false); $clang->load($extension, $path, 'en-GB', false, false); $clang->load($extension, $path, $lang->getDefault(), false, false); $jsLang = array_diff_assoc($clang->getStrings(), $strings); $lang->load($extension, $path, null, false, false); $lang->load($extension, $path, 'en-GB', false, false); $lang->load($extension, $path, $lang->getDefault(), false, false); // Add them to the header foreach (array_keys($jsLang) as $key) { JText::script($key); } }