How to use separate language files for opencart multi stores?

一曲冷凌霜 提交于 2019-12-12 13:34:38

问题


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!


回答1:


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']
            );  
        }
    }


来源:https://stackoverflow.com/questions/16161348/how-to-use-separate-language-files-for-opencart-multi-stores

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!