Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use separate language files for opencart multi stores?

I'm using opencart version 1.5.5.1. We've a website coded using opencart framework. The site uses opencart multi-store feature also. All stores use English language.

Now the question is, is it possible to use different language labels for different stores? For example: One store is related to sports items and another one is related to wrist watches. So we need to use language labels related to sports items in one store and language labels related to watches for the other one.

I'm not sure whether it's possible or not, as in opencart we load the language files via controller file of each module.

Please help me. Thanks in advance!

like image 424
Sankar V Avatar asked Dec 17 '25 04:12

Sankar V


1 Answers

Not sure if this is the most elegant way, but here's a hack that first came to mind:

  1. Create multiple languages in Admin, i.e. English_sports, English_watches, French_sports etc.
  2. in catalog/comtroller/module/language.php add a conditional statement to catch and filter out not needed languages:

Find line 32:

$results = $this->model_localisation_language->getLanguages();

Add:

$store_id = $this->config->get('config_store_id');

Inside data population loop add your conditional and string cleaning code:

foreach ($results as $result) {
    if ($store_id == "0" && $result['name'] == 'English_sports'){continue;} 
    $strings = array("_sports","_watches");
        if ($result['status']) {
            $this->data['languages'][] = array(
                //clean name strings for output
                'name'  => str_replace($strings,'',$result['name']),
                'code'  => $result['code'],
                'image' => $result['image']
            );  
        }
    }
like image 160
B-and-P Avatar answered Dec 19 '25 22:12

B-and-P



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!