Jump to content

how to change language in ebay 1.5.3?


David475

Recommended Posts

hi

 

i trying to change the default language in ebay module for english

 

this is the EbayCountrySpec.php

<?php

if (!in_array('Ebay', get_declared_classes()))
		require_once(dirname(__FILE__).'/../ebay.php');

class EbayCountrySpec
{
	public $country;
	public $accepted_isos = array('it', 'fr', 'gb', 'es');

	private $country_data = array(
		'it' => array(
			'site_id' => 101,
			'language' => 'it_IT',
			'currency' => 'EUR',
			'site_name' => 'Italy',
			'site_extension' => 'it',
			'img_stats' => null
		),
		'gb' => array(
			'site_id' => 3,
			'language' => 'en_GB',
			'currency' => 'GBP',
			'site_name' => 'UK',
			'site_extension' => 'co.uk',
			'img_stats' => null
		),
		'es' => array(
			'site_id' => 186,
			'language' => 'es_ES',
			'currency' => 'EUR',
			'site_name' => 'Spain',
			'site_extension' => 'es',
			'img_stats' => null
		),
		'fr' => array(
			'site_id' => 71,
			'language' => 'fr_FR',
			'currency' => 'EUR',
			'site_name' => 'France',
			'site_extension' => 'fr',
			'img_stats' => 'views/img/ebay_stats.png'
		)
	);

	public function __construct(Country $country = null)
	{
		if ($country != null)
			$this->country = $country;
		else
			$this->country = $this->_getCountry();
	}

	public function getSiteID()
	{
		return $this->_getCountryData('site_id');
	}

	public function getLanguage()
	{
		return $this->_getCountryData('language');
	}

	public function getCurrency()
	{
		return $this->_getCountryData('currency');
	}

	public function getSiteName()
	{
		return $this->_getCountryData('site_name');
	}

	public function getSiteExtension()
	{
		return $this->_getCountryData('site_extension');
	}

	public function getImgStats()
	{
		return $this->_getCountryData('img_stats');
	}

	public function getIsoCode()
	{
		if (!$this->country)
			return null;
		return $this->country->iso_code;
	}

	public function getIdLang()
	{
		$id_lang = Language::getIdByIso($this->getIsoCode());
		if (!$id_lang) //Fix for UK
			$id_lang = Configuration::get('PS_LANG_DEFAULT');
		return (int)$id_lang;
	}

	private function _getCountryData($data)
	{
		$iso_code = strtolower($this->country->iso_code);
		if (isset($this->country_data[$iso_code]))
			return $this->country_data[$iso_code][$data];
		return $this->country_data['fr'][$data];
	}

	/**
	* Tools Methods
	*
	* Sends back true or false
	**/
	public function checkCountry()
	{
		if (in_array(strtolower($this->country->iso_code), $this->accepted_isos))
			return true;
		return false;
	}

	/**
	* Tools Methods
	*
	* Set country
	*
	**/
	private function _getCountry()
	{
		// If eBay module has already been called once, use the default country
		if (!is_object($this->country))
			$this->country = new Country((int)Configuration::get('EBAY_COUNTRY_DEFAULT'));

		// Else use PrestaShop Default country
		if (in_array(strtolower($this->country->iso_code), $this->accepted_isos))
			return $this->country;

		$this->country = new Country((int)Configuration::get('PS_COUNTRY_DEFAULT'));

		if (in_array(strtolower($this->country->iso_code), $this->accepted_isos))
			Configuration::updateValue('EBAY_COUNTRY_DEFAULT', $this->country->id, false, 0, 0);
		return $this->country;
	}
}

help will be appreciated. thanks

Edited by David475 (see edit history)
Link to comment
Share on other sites

  • 2 weeks later...

Did this not work ? 

 

 

 

in this version the getIdLang() is in a function and when i edited it freezes my store. The default lang in the shop is english ( but activated with spanish, italian, french and portuguese) and the default country is set to Spain.

 

any idea? :)

Link to comment
Share on other sites

  • 1 month later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...