如何为opencart多个商店使用单独的语言文件? [英] How to use separate language files for opencart multi stores?

查看:116
本文介绍了如何为opencart多个商店使用单独的语言文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用opencart版本1.5.5.1.我们有一个使用opencart框架编码的网站.该网站还使用opencart多商店功能.所有商店都使用英语.

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.

我不确定是否可行,因为在opencart中,我们通过每个模块的控制器文件加载语言文件.

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!

推荐答案

不确定这是否是最优雅的方法,但这是首先想到的一个hack:

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

  1. 在Admin中创建多种语言,即English_sportsEnglish_watchesFrench_sports等.
  2. catalog/comtroller/module/language.php中添加条件语句以捕获并过滤出不需要的语言:
  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:

找到第32行:

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

添加:

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

这篇关于如何为opencart多个商店使用单独的语言文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆