/** * Method to add translation strings to JS translation object * * @param $strings Associative array with list of strings to translate * */ public static function addJsTranslationStrings($strings) { if (self::$added_strings === null) { self::$added_strings = array(); } JHTML::_('script', 'tienda_lang.js', 'media/com_tienda/js/'); $js_strings = array(); for ($i = 0, $c = count($strings); $i < $c; $i++) { if (in_array(strtoupper($strings[$i]), self::$added_strings) === false) { $js_strings[] = '"' . strtoupper($strings[$i]) . '":"' . JText::_($strings[$i]) . '"'; self::$added_strings[] = strtoupper($strings[$i]); } } if (count($js_strings)) { $doc = JFactory::getDocument(); $doc->addScriptDeclaration('Joomla.JText.load({' . implode(',', $js_strings) . '});'); } }