如果 en-gb.php 语言文件仅在管理员中不起作用,如何解决

how to fix if en-gb.php language file not working in only admin

我在 Opencart 3.0.2.0 中遇到问题,所有语言文件在页面中显示其文本和变量,并且在管理中完美运行,en-gb.php 除外。请看下图。

我尝试调试但无法修复 it.I 还检查了 "storage" 修改文件以查看是否有任何文件被覆盖,但所有地方都是相同的代码。

你可以看到下面这段代码已经写在en-gb.php但是它的变量值没有显示在任何管理页面中。

$_['code']                          = 'en';
$_['direction']                     = 'ltr';
$_['date_format_short']             = 'd/m/Y';
$_['date_format_long']              = 'l dS F Y';
$_['time_format']                   = 'h:i:s A';
$_['datetime_format']               = 'd/m/Y H:i:s';
$_['decimal_point']                 = '.';
$_['thousand_point']                = ',';

以下是我将采取的解决此问题的步骤:

  1. 在管理 -> 系统 -> 本地化 -> 语言中检查语言设置。它应该是这样的 http://joxi.ru/eAOYwZkU9EDEDm

  2. 在管理员 -> 系统 -> 设置 -> 编辑您的商店并访问本地选项卡中检查 opencart 商店设置。应该是这样的 http://joxi.ru/nAyxya7FgGbGv2

  3. 然后在管理 -> 设计 -> 语言编辑器中检查 opencart 语言编辑器。应该看起来像这样 http://joxi.ru/E2p1aYlS7VxVEA

  4. 如果一切正确,让我们检查代码。在 admin/language/en-gb/en-gb.php 中。应该看起来像这样 http://joxi.ru/V2VLwxqSdVqVyr

  5. 然后检查system/storage/modifications/admin/language/en-gb/en-gb处的语言文件是否有任何修改。php(该文件应该不存在)

  6. 如果你安装了 vqmod,我也会检查 vqmod/vqcache/...

  7. 中的缓存

if all of this is correct, we need to dig deeper into the core of OpenCart

  1. admin中的语言文件eb-gb(也是语言目录的名字)被控制器加载admin/startup/startup.php第27行
$language->load($this->config->get('config_admin_language'));

因此您可以通过 return 像这样在其后输入值来检查此代码:

$language->load($this->config->get('config_admin_language'));
//this will output everything that is currently in the languge ibject.
print_r($language);

它应该是这样的 http://joxi.ru/l2ZRw70szkLLl2

如果它不是 return 数组,问题可能是此代码未正确加载或结果在某处被空数组覆盖。

如果您的商店有修改,您将需要检查 system/storage/modifications 并搜索任何可能执行类似操作的代码

  1. 如果那是正确的,那么还有一个地方需要检查。在 admin/event/language.php 中,您可能遇到了一些问题。在第 9 行添加此代码
public function index(&$route, &$args) {
    foreach ($this->language->all() as $key => $value) {
        if (!isset($args[$key])) {
            $args[$key] = $value;
        }
    }
    // this will output the current values of the language object with the route name.
    echo $route;
    echo '<pre>';
    print_r($args);
    echo '</pre>'; 
}

它应该是这样的 http://joxi.ru/DmBL9V6SJPWjWA

如果在像 common/footer 这样的特定路线之后的某个时刻,您发现 text_home 为空或丢失,那么您需要检查该路线及其修改,看看那里发生了什么。

  1. 如果 none 有帮助,请在 https://dreamvention.ee/support 向我们发送票证,我会亲自查看。

希望这对您有所帮助。