Post by anatom09 » Sat Jul 07, 2018 1:36 pm

Hello,
I am having an opencart at Greek and English. Default language is set to Greek. When I access the website from a clean from any cookies browser, the English version comes first instead of the Greek.

Also, I noticed that I might be looking at the Greek SEO url and the content be in English!

For example, this link:
https://www.multiclima.gr/werstahl-hercules-hs40 should be in Greek
and this link:
https://www.multiclima.gr/werstahl-hercules-40 should be in English.

What happens, is that if I visit the product through clicking on it from the homepage while being in the Greek version of the site, I am lead to https://www.multiclima.gr/werstahl-hercules-hs40 correctly. If i switch to English using the language drop menu, the language changes but the url stays the same (https://www.multiclima.gr/werstahl-hercules-hs40) and doesnt change to https://www.multiclima.gr/werstahl-hercules-40 as it should.
If I click again to change back to Greek thtough the language menu, the url changes to https://www.multiclima.gr/werstahl-hercules-40 which should be the English SEO url English but now is Greek! If I change back to English now, the English url will be https://www.multiclima.gr/werstahl-hercules-hs40 which should be the Greek.

So now, I have 2 English urls and 2 Greek urls for the same page. (Duplicate content?)

I searched and found similar threads in the internet, and in github, with people having the same problem, but no solution anywhere. Any ideas?

All the above is a large problem for me. Yesterday I sent my xml product feed to a price comparison website, and they told me that their system detected the english version and that they needed the Greek version. The product feed url is always the same regardless of the language. It is not like Joomla that has a /en /it /de etc for each language. How can this be solved. I am thinking of completely deactivating English, although I wanted a multilingual site.

Κατασκευή eshop με Opencart & τεχνική υποστήριξη.


Newbie

Posts

Joined
Sat Jul 07, 2018 1:00 pm


Post by straightlight » Sat Jul 07, 2018 10:22 pm

This has been covered before on the forum. It is NOT duplicated content. It is simply an issue with v3.0.2.0 regarding the language switching. Since you're using the SEO links, more information is needed. Are you using the one from the core or one from the Marketplace? Disable the SEO links and see, by switching languages if the same issue occurs.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by paulfeakins » Mon Jul 09, 2018 5:30 pm


For quick, professional OpenCart support please email info@antropy.co.uk


User avatar
Guru Member

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - Reigate, Surrey, United Kingdom

Post by straightlight » Mon Jul 09, 2018 8:12 pm

paulfeakins wrote:
Mon Jul 09, 2018 5:30 pm
This might do what you need:
https://www.opencart.com/index.php?rout ... n_id=21827
2.x releases only. This request has been created in the v3.x releases.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by gxHL » Sun Feb 09, 2020 12:58 am

Same issue is happening on 3.0.3.2, I have tried with a clean installation.

https://myopencartshop.com/hp-lp3065-el and https://myopencartshop.com/hp-lp3065-en

Showing the same default English language.
Anyone has a fix on this?

Newbie

Posts

Joined
Sun Mar 24, 2013 7:52 pm

Post by straightlight » Sun Feb 09, 2020 2:17 am

gxHL wrote:
Sun Feb 09, 2020 12:58 am
Same issue is happening on 3.0.3.2, I have tried with a clean installation.

https://myopencartshop.com/hp-lp3065-el and https://myopencartshop.com/hp-lp3065-en

Showing the same default English language.
Anyone has a fix on this?
As many custom jobs I did for store owners, this behavior never happened to me with a clean installation and don't know how both of you are able to reach that point if no extensions are involved in the process. I do notice, however, you are using SEO links. Are you using any extensions with the SEOs?

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by letxobnav » Sun Feb 09, 2020 2:25 am

OC does not determine language based on url as there is no language code in the url and the seo url logic does not take language into account at all.
That is why bots always get your pages in your default language regardless of which url they request (most bots do not send a language accept header), that is where your duplicate content comes from. french url, greek url, spanish url will result in the page in your default language for bots, always.

The language switching is flawed as its class sets a redirect link while still in the current language, once redirected, it does set the page language correctly via the session varable but the url has already been set and remains the same, i.e. the old language. That is how it is set up and wrong.

instead of setting the redirect link in the index function, the redirect link should be determined in the language function by taking the posted language code, determine the language_id from that and set it in the config. Then construct the redirect url as the seo url link logic uses that variable and redirect.

You will find more things wrong with the default multi-language provisions in OC as they are an afterthought.
Last edited by letxobnav on Sun Feb 09, 2020 2:38 am, edited 1 time in total.

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by gxHL » Sun Feb 09, 2020 2:32 am

straightlight wrote:
Sun Feb 09, 2020 2:17 am
As many custom jobs I did for store owners, this behavior never happened to me with a clean installation and don't know how both of you are able to reach that point if no extensions are involved in the process. I do notice, however, you are using SEO links. Are you using any extensions with the SEOs?
I have sent you a clean demo store that I have created with the issue visible.
I hope you can confirm that that's the case.
letxobnav wrote:
Sun Feb 09, 2020 2:25 am
OC does not determine language based on url as there is no language code in the url and the seo url logic does not take language into account at all.
That is why bots always get your pages in your default language regardless of which url they request (most bots do not send a language accept header), that is where your duplicate content comes from. french url, greek url, spanish url will result in the page in your default language for bots, always.

The language switching is flawed as its class sets a redirect link while still in the current language, once redirected, it does set the page language correctly via the session varable but the url has already been set and remains the same, i.e. the old language. That is how it is set up and wrong.

You will find more things wrong with the default multi-language provisions in OC as they are an afterthought.
Great...

Newbie

Posts

Joined
Sun Mar 24, 2013 7:52 pm

Post by letxobnav » Sun Feb 09, 2020 2:46 am

instead of setting the redirect link in the index function, the redirect link should be determined in the language function by taking the posted language code, determine the language_id from that and set it in the config. Then construct the redirect url as the seo url link logic uses that variable and redirect.
as I edited in my previous post, it is not that difficult to switch languages with url correctly but the common/language class has to be changed.
For the bot issue, getting the page in the language of the url requested, you would need to change the url logic to include a language code as the system cannot determine if a url (its individual keywords) is in french or english.

I have it easy as I only have english and chinese and since chinese is multi-byte, I only need to check if the url contains multi-byte characters to determine if it is in chinese and set the language accordingly. That aside, I still add a language code to the url because if I were to add another language I would again have the same problem.

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by erhangazi84 » Fri Oct 16, 2020 7:03 am

anatom09 wrote:
Sat Jul 07, 2018 1:36 pm
Hello,
I am having an opencart at Greek and English. Default language is set to Greek. When I access the website from a clean from any cookies browser, the English version comes first instead of the Greek.

Also, I noticed that I might be looking at the Greek SEO url and the content be in English!

For example, this link:
https://www.multiclima.gr/werstahl-hercules-hs40 should be in Greek
and this link:
https://www.multiclima.gr/werstahl-hercules-40 should be in English.
hello anatom09
Could you solve this problem?

I am having the same problem. i am using 3.0.3.2 and have installed a new and clean OC 3.0.3.6 on another domain and result is same.

I am using Turkish languge, URL is Turkish, i click English flag, URL stay same but content changes into English. And then, i click back to Turkish, URL changes to English but content changes into Turkish.

Very funny.

User avatar
Newbie

Posts

Joined
Fri May 23, 2014 10:46 pm
Location - Gaziantep,Turkey

Post by letxobnav » Fri Oct 16, 2020 10:49 am

There are two ways to do that (controller common/language):
1) instead of just adding the current url as redirect url to the language form, you have to add the seo urls of all you languages to that form (function index). Then when a language code is selected find the seo url belonging to that code from the post variables and redirect (function language).
2) instead of using a redirect url in the form (function index), save the get variables (except for preload,prefetch and ajax requests, done in a separate controller) and use the saved get variables to construct the redirect url after the language has been chosen (function language).

we use option 2 as we save the get variables anyway for url history (continue button purposes) but option 1 might be more simple for most.

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by erhangazi84 » Fri Oct 16, 2020 4:21 pm

hello friend.

If it is not so difficult for you, can you pls explain both ways so that we OC users try either of them?
Language switcher URL is a really big issue and no exact solution in anywhere.

Regards

User avatar
Newbie

Posts

Joined
Fri May 23, 2014 10:46 pm
Location - Gaziantep,Turkey

Post by letxobnav » Fri Oct 16, 2020 11:09 pm

for option 1, the simplest:

1) replace your catalog/controller/common/language.php with this:

Code: Select all

<?php
class ControllerCommonLanguage extends Controller {
	public function index() {
		$this->load->language('common/language');
		$data['action'] = $this->url->link('common/language/language', '', $this->request->server['HTTPS']);
		$data['code'] = $this->session->data['language'];
		$this->load->model('localisation/language');
		$data['languages'] = array();
		$results = $this->model_localisation_language->getLanguages();
		
		/***** save current language id ****/
		$language_id_save = $this->config->get('config_language_id');
		
		foreach ($results as $result) {
			if ($result['status']) {
				
				/****** determine redirect url for language ******/
				$this->config->set('config_language_id',$result['language_id']);
				$this->session->data['language'] = $result['code'];
				
				if (!isset($this->request->get['route'])) {
					$url_data = $this->request->get;
					unset($url_data['_route_']);
					if ($url_data) $url = '&' . urldecode(http_build_query($url_data, '', '&'));
					$redirect = $this->url->link('common/home', $url, $this->request->server['HTTPS']);
				} else {
					$url_data = $this->request->get;
					unset($url_data['_route_']);
					$route = $url_data['route'];
					unset($url_data['route']);
					if ($url_data) $url = '&' . urldecode(http_build_query($url_data, '', '&'));
					$redirect = $this->url->link($route, $url, $this->request->server['HTTPS']);
				}
				$data['languages'][] = array(
					'name' => $result['name'],
					'code' => $result['code'],
					'href' => $redirect
				);
			}
		}
		/**** restore current language id and code ****/
		$this->session->data['language'] = $data['code'];
		$this->config->set('config_language_id',$language_id_save);
		
		return $this->load->view('common/language', $data);
	}
	
	public function language() {
		$this->load->model('localisation/language');
		$languages = $this->model_localisation_language->getLanguages();
		$url = '';
		if (isset($this->request->post['code']) && array_key_exists($this->request->post['code'],$languages) && $languages[$this->request->post['code']]['status']) {
			/**** set the requested language ****/
			$this->session->data['language'] = $this->request->post['code'];
			/**** use the correct redirect ****/
			$this->response->redirect($this->request->post['redirect_'.$this->request->post['code']]);
		} else {
			$this->response->redirect($this->url->link('common/home', $url, $this->request->server['HTTPS']));
		}
	}
}
2) replace your catalog/view/them/default/template/common/language.twig with this:

Code: Select all

{% if languages|length > 1 %}
<div class="pull-left">
  <form action="{{ action }}" method="post" enctype="multipart/form-data" id="form-language">
    <div class="btn-group">
      <button class="btn btn-link dropdown-toggle" data-toggle="dropdown">
      {% for language in languages %}
      {% if language.code == code %} 
      <img src="catalog/language/{{ language.code }}/{{ language.code }}.png" alt="{{ language.name }}" title="{{ language.name }}">
      {% endif %}
      {% endfor %}
      <span class="hidden-xs hidden-sm hidden-md">{{ text_language }}</span>&nbsp;<i class="fa fa-caret-down"></i></button>
      <ul class="dropdown-menu">
        {% for language in languages %}
        <li>
          <button class="btn btn-link btn-block language-select" type="button" name="{{ language.code }}"><img src="catalog/language/{{ language.code }}/{{ language.code }}.png" alt="{{ language.name }}" title="{{ language.name }}" /> {{ language.name }}</button>
        </li>
		<input type="hidden" name="redirect_{{ language.code }}" value="{{ language.href }}" />
        {% endfor %}
      </ul>
    </div>
    <input type="hidden" name="code" value="" />
  </form>
</div>
{% endif %}

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan
Who is online

Users browsing this forum: No registered users and 37 guests