问题
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:
- Create multiple languages in Admin, i.e.
English_sports
,English_watches
,French_sports
etc. - 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