• Home
  • Get help
  • Ask a question
Last post 1 hour 8 min ago
Posts last week 94
Average response time last week 34 min
All time posts 67850
All time tickets 10486
All time avg. posts per day 20

Helpdesk is open from Monday through Friday CET

Please create an (free) account to post any question in the support area.
Please check the development versions area. Look at the changelog, maybe your specific problem has been resolved already!
All tickets are private and they cannot be viewed by anyone. We have made public only a few tickets that we found helpful, after removing private information from them.

#119 – Error message when i change sh404sef to my language

Posted in ‘sh404SEF’
This is a public ticket. Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.
Monday, 20 April 2015 18:01 UTC
vinhnx
Hi .
I use joomla with my language (vietnam - vi-VN) , i got a message after i change jooma from english to my language . Please support me how to fix it for my site , i have created screenshot in my attach file .

thanks

Notice: Undefined index: vi-VN in /Applications/XAMPP/xamppfiles/htdocs/vietmask/site/administrator/components/com_sh404sef/helpers/language.php on line 164

Notice: Trying to get property of non-object in /Applications/XAMPP/xamppfiles/htdocs/vietmask/site/administrator/components/com_sh404sef/helpers/language.php on line 164
 

-> This is language.php code :

<?php
/**
 * sh404SEF - SEO extension for Joomla!
 *
 * @author      Yannick Gaultier
 * @copyright   (c) Yannick Gaultier - Weeblr llc - 2015
 * @package     sh404SEF
 * @license     http://www.gnu.org/copyleft/gpl.html GNU/GPL
 * @version     4.4.8.2409
 * @date		2015-04-05
 */

// Security check to ensure this file is being included by a parent file.
defined('_JEXEC') or die;

class Sh404sefHelperLanguage
{
	/**
	 * Figures out if a language code should be inserted
	 * into urls for default language
	 * 
	 */
	public static function getInsertLangCodeInDefaultLanguage()
	{
		static $shouldInsert = null;

		if (is_null($shouldInsert))
		{
			// default Joomla value is true
			// sh404SEF default always been false
			$shouldInsert = false;

			// try load languagefilter plugin params
			$plugin = JPluginHelper::getPlugin('system', 'languagefilter');
			if (!empty($plugin))
			{
				$params = new JRegistry();
				$params->loadString($plugin->params);
				$shouldInsert = $params->get('remove_default_prefix', false);
				$shouldInsert = empty($shouldInsert);
			}
		}

		return $shouldInsert;
	}

	public static function getLanguageFilterWarning()
	{
		static $displayed = false;

		if (!$displayed)
		{
			$displayed = true;
			$app = JFactory::getApplication();

			// figure out whether we should display the warning
			// only on html page, and on display or info tasks
			$format = $app->input->getCmd('format', 'html');
			if ($format != 'html')
			{
				return '';
			}
			$task = $app->input->getCmd('task', 'display');
			if ($task != 'display' && $task != 'info')
			{
				return '';
			}

			// only if this is supposed to be a ML site
			// that would be if the not-used anymore enableMultiLingualSupport
			// was false
			$sefConfig = Sh404sefFactory::getConfig();
			if (!$sefConfig->enableMultiLingualSupport)
			{
				return '';
			}

			// or if there's only one language on the site
			$languages = JLanguageHelper::getLanguages('sef');
			if (count($languages) <= 1)
			{
				return '';
			}

			// and only if the plugin is not enabled ofc
			$plugin = JPluginHelper::getPlugin('system', 'languagefilter');
			if (!empty($plugin))
			{
				return '';
			}

			// insert message
			$message = JText::_('COM_SH404SEF_LANGUAGEFILTER_PLUGIN_WARNING');
			if (version_compare(JVERSION, '3.0', 'ge'))
			{
				return ShlMvcLayout_Helper::render('com_sh404sef.general.warning', array('warning' => $message));
			}
			else
			{
				return $message;
			}
		}

	}

	/**
	 * Find a language family
	 *
	 * @param object $language a Joomla! language object
	 * @return string a 2 or 3 characters language family code
	 */
	public static function getFamily($language = null)
	{
		if (!is_object($language))
		{
			// get application db instance
			$language = JFactory::getLanguage();
		}

		$code = $language->get('lang');
		$bits = explode('-', $code);
		return empty($bits[0]) ? 'en' : $bits[0];
	}

	/**
	 * Get language tag from a url language code
	 * 
	 * @param string $langCode
	 * @return string
	 */
	public static function getLangTagFromUrlCode($langCode)
	{

		$languages = JLanguageHelper::getLanguages('sef');
		if (!empty($languages[$langCode]))
		{
			$urlLangTag = $languages[$langCode]->lang_code;
		}
		else
		{
			$urlLangTag = self::getDefaultLanguageTag();
		}

		return $urlLangTag;
	}

	/**
	 * Get url short language code from a full language tag
	 *
	 * @param string $langTag
	 * @param bool $default if true, return code for default language if not found
	 * @return string
	 */
	public static function getUrlCodeFromTag($langTag, $default = true)
	{
		$languages = JLanguageHelper::getLanguages('lang_code');
		if (!empty($languages[$langTag]))
		{
			$urlLangCode = $languages[$langTag]->sef;
		}
		else if ($default)
		{
			$urlLangTag = self::getDefaultLanguageTag();
			$urlLangCode = $languages[$urlLangTag]->sef;
		}
		else
		{
			$urlLangCode = null;
		}

		return $urlLangCode;
	}

	public static function validateSefLanguageCode($sefLangCode)
	{
		static $codes = null;

		if(!isset($codes[$sefLangCode]))
		{
			$availableLanguages = self::getInstalledLanguagesList();
			foreach ($availableLanguages as $language)
			{
				if ($sefLangCode == $language->sef)
				{
					$codes[$sefLangCode] = true;
					return true;
				}
			}
			$codes[$sefLangCode] = false;
		}

		return $codes[$sefLangCode];
	}

	public static function getDefaultLanguageSef()
	{
		return self::getUrlCodeFromTag(self::getDefaultLanguageTag());
	}

	/**
	 * Get installed front end language list
	 *
	 * @access  private
	 * @return  array
	 */
	public static function getInstalledLanguagesList($site = true)
	{
		static $languages = null;

		if (is_null($languages))
		{
			$db = ShlDbHelper::getDb();

			// is there a languages table ?
			$languages = array();
			$languagesTableName = $db->getPrefix() . 'languages';
			$tablesList = $db->getTableList();
			if (is_array($tablesList) && in_array($languagesTableName, $tablesList))
			{
				try
				{
					$query = 'SELECT * FROM #__languages';
					$db->setQuery($query);
					$languages = $db->loadObjectList();
				}
				catch (Exception $e)
				{
					JError::raiseWarning('SOME_ERROR_CODE', "Error loading languages lists: " . $e->getMessage());
					ShlSystem_Log::error('sh404sef', '%s::%s::%d: %s', __CLASS__, __METHOD__, __LINE__, $e->getMessage());
					return false;
				}
				// match fields name to what we need, those were changed in version 2.2 of JF
				foreach ($languages as $key => $language)
				{
					if (empty($language->id))
					{
						$languages[$key]->id = $language->lang_id;
					}
					if (empty($language->name))
					{
						$languages[$key]->name = $language->title;
					}
					if (empty($language->code))
					{
						$languages[$key]->code = $language->lang_code;
					}
					if (empty($language->shortcode))
					{
						$languages[$key]->shortcode = $language->sef;
					}
					if (empty($language->active) && empty($language->published))
					{
						// drop this language, it is not published
						unset($languages[$key]);
					}
				}
			}
		}

		return $languages;
	}

	/**
	 * Returns the full language tag for the site default language
	 * 
	 * @return string
	 */
	public static function getDefaultLanguageTag()
	{
		return JComponentHelper::getParams('com_languages')->get('site', 'en-GB');
	}

	/**
	 * Returns the full language tag for the site default language
	 *
	 * @return string
	 */
	public static function getLanguageFilterPluginParam($paramName, $default = null)
	{
		static $params = null;

		if (is_null($params))
		{
			$plugin = JPluginHelper::getPlugin('system', 'languagefilter');
			$params = new JRegistry();
			$params->loadString(empty($plugin) ? '' : $plugin->params);
		}

		return is_null($params) ? $default : $params->get($paramName, $default);
	}

	/**
	 * Sets a Jooml! language cookie, deleting existing one if any
	 * 
	 * @param string $languageCode the new target language code (ie: en-GB)
	 * @param int $cookieTime cookie duration time, set in params or default to 0
	 */
	public static function setLanguageCookie($languageCode = null, $cookieTime = 0)
	{
		$languageCode = empty($languageCode) ? Sh404sefHelperLanguage::getDefaultLanguageTag() : $languageCode;
		// Create a cookie
		$conf = JFactory::getConfig();
		$cookieName = JApplication::getHash('language');
		$cookieDomain = $conf->get('config.cookie_domain', '');
		$cookiePath = $conf->get('config.cookie_path', '/');
		// set new cookie, both in browser and in internal application vars
		$app = JFactory::getApplication();
		$app->input->cookie->set($cookieName, $languageCode, $cookieTime, $cookiePath, $cookieDomain, false, true);
		JRequest::setVar($cookieName, $languageCode, 'cookie');
		// as Joomla languagefilter also sets this cookie disregarding the path,domain and duration parameters, we must set it twice
		$app->input->cookie->set($cookieName, $languageCode);
	}

}

Monday, 20 April 2015 18:17 UTC
wb_weeblr
Hi,

Does this problem happens with Joomla 3.4.1?

Can you please update to current development version? you can download it from https://copy.com/xxxx

Rgds
 
Tuesday, 21 April 2015 03:10 UTC
vinhnx
Hi Weeblr ,

1. No ,I use joomla 3.3.6 show in screenshot .

2. I want to do language for sh404 component . How to do it ?

I have create 4 file and content of file is same with en-GB.com_sh404sef.ini , other files .

- vi-VN.com_sh404sef.acesef.ini 
- vi-VN.com_sh404sef.ini
- vi-VN.com_sh404sef.joomsef.ini
- vi-VN.com_sh404sef.sys.ini

Tuesday, 21 April 2015 07:14 UTC
vinhnx
Error in Front-page in attach file .
Notice: Undefined index: vi-VN in /Applications/XAMPP/xamppfiles/htdocs/vietmask/site/administrator/components/com_sh404sef/helpers/language.php on line 164

Notice: Trying to get property of non-object in /Applications/XAMPP/xamppfiles/htdocs/vietmask/site/administrator/components/com_sh404sef/helpers/language.php on line 164

Notice: Undefined index: vi-VN in /Applications/XAMPP/xamppfiles/htdocs/vietmask/site/administrator/components/com_sh404sef/helpers/language.php on line 164

Notice: Trying to get property of non-object in /Applications/XAMPP/xamppfiles/htdocs/vietmask/site/administrator/components/com_sh404sef/helpers/language.php on line 164

Notice: Undefined index: vi-VN in /Applications/XAMPP/xamppfiles/htdocs/vietmask/site/administrator/components/com_sh404sef/helpers/language.php on line 164

Notice: Trying to get property of non-object in /Applications/XAMPP/xamppfiles/htdocs/vietmask/site/administrator/components/com_sh404sef/helpers/language.php on line 164
Tuesday, 21 April 2015 08:27 UTC
vinhnx
Hi again ,

1. I Have add a row to #__languages and everything is working good (screenshot in my attach) but I don't understand why ?

In my Condition , I find in /Applications/XAMPP/xamppfiles/htdocs/vietmask/site/administrator/components/com_sh404sef/helpers/language.php and i come to libraries/joomla/language/helper.php and see function getLanguage().


/**
	 * Get available languages
	 *
	 * @param   string  $key  Array key
	 *
	 * @return  array  An array of published languages
	 *
	 * @since   11.1
	 */
	public static function getLanguages($key = 'default')
	{
		static $languages;

		if (empty($languages))
		{
			// Installation uses available languages
			if (JFactory::getApplication()->getClientId() == 2)
			{
				$languages[$key] = array();
				$knownLangs = JLanguage::getKnownLanguages(JPATH_BASE);

				foreach ($knownLangs as $metadata)
				{
					// Take off 3 letters iso code languages as they can't match browsers' languages and default them to en
					$obj = new stdClass;
					$obj->lang_code = $metadata['tag'];
					$languages[$key][] = $obj;
				}
			}
			else
			{
				$cache = JFactory::getCache('com_languages', '');

				if (!$languages = $cache->get('languages'))
				{
					$db = JFactory::getDbo();
					$query = $db->getQuery(true)
						->select('*')
						->from('#__languages')
						->where('published=1')
						->order('ordering ASC');
					$db->setQuery($query);

					$languages['default'] = $db->loadObjectList();
					$languages['sef'] = array();
					$languages['lang_code'] = array();

					if (isset($languages['default'][0]))
					{
						foreach ($languages['default'] as $lang)
						{
							$languages['sef'][$lang-&gt;sef] = $lang;
							$languages['lang_code'][$lang-&gt;lang_code] = $lang;
						}
					}

					$cache->store($languages, 'languages');
				}
			}
		}

		return $languages[$key];
	}
Tuesday, 21 April 2015 10:25 UTC
wb_weeblr
Hi

Because it looks like you vietnamese language pack doesn't add the proper content in #_languages.
That is it doesn't register vietnamese as Joomla content. Or there was some error during installation that caused the vi language to be missing in the Joomla "content" language tab.

Rgds
 
Tuesday, 21 April 2015 10:28 UTC
wb_weeblr
I mean "Installation of the language pack".

That's not a programming error, just a consequence. I have added a check now so that even if this happens (missing language in "content" tab), no error is displayed.

Also, to translate sh404SEF, you only need to touch the 2 following files:

- vi-VN.com_sh404sef.ini
- vi-VN.com_sh404sef.sys.ini

The two others are legacy and will be removed in the future.

Are you a programmer?

Rgds
 
Tuesday, 21 April 2015 11:13 UTC
vinhnx
Hi Weeblr ,

1. yes , I am programmer from vietnam . Last time , i use sh404sef but i only use null version from internet . This is useful component .

2.my problem is solved .

3.Can you compare routing in Joomla with router.php and routing with sh404sef about performance of website ?


Thanks you.
Tuesday, 21 April 2015 11:15 UTC
vinhnx
Tuesday, 21 April 2015 12:16 UTC
wb_weeblr
A bout perf, it depends on the type of sites you have. Usually, you can expect a 5 to 20% perf penalty on the server page creation time - because page creation time is small compared to connection, download, etc.
This is usually not a problem, and it depends a lot on how the plugins are written.

Do you do custom programming work?

Rgds
 
Tuesday, 21 April 2015 12:50 UTC
vinhnx
1.No, I worked 5 years in outsourcing company and 2 years in travel company , I think it's enough for me . Now i like to start-up Travel Company with my wife and friends .

2.Thanks your support , Call you "Sir" ( i am 30 year old , i saw your picture on menu Blog of this site). I think you are older than me and i will continue ask and learn from you . :)
This ticket is closed, therefore read-only. You can no longer reply to it. If you need to provide more information, please open a new ticket and mention this ticket's number.