Direct link to language in OpenCart

multilingualopencart

I have a website(built with OpenCart) with multiple languages, e.g. English, German, French.
Users can change language using default functionality of the OpenCart – clicking on language icons on top.

Is it possible to send users automaticaly (so they don't have to click on the flag) from :
Germany to German version of the website
France to French version of the website
(English language is default)

Is there an URL I can use for these languages if the default page is for example http://mystore.com ?
(I noticed that when I click on the language icon the URL is not changing – it's the same for all languages)

Best Answer

Nowadays opencart doesn't support this function, but in the past , older versions of Opencart did have this function.

If you want to include this function in your website you will have to do the following:

Edit this file: catalog/controller/module/language.php

find this:

    class ControllerModuleLanguage extends Controller {
        protected function index() {
            if (isset($this->request->post['language_code'])) {

before the "if", you will have to include the following :

if (isset($this->request->get['lang'])) {

    $this->session->data['language'] = $this->request->get['lang'];

    if (isset($_SERVER['HTTP_REFERER']) && (strpos($_SERVER['HTTP_REFERER'], $this->config->get('config_url')) !== false) ) {

        $this->redirect($_SERVER['HTTP_REFERER']);

    } else {

        $this->redirect($this->url->link('common/home'));

    }

} else  {

The source

An example of website with this code:

http://incomingtospain.com/madrid&lang=de

http://incomingtospain.com/madrid&lang=ru

This website has 8 idioms and you can access by different url, with this variable "lang" &lang=es &lang=en ... &lang=de &lang=ru

Related Topic