在前端,如何在“打开购物车"中安装的不同语言中获取哪种语言处于活动状态? [英] In frontend how to get which language is active among installed different languages in Open cart?

查看:53
本文介绍了在前端,如何在“打开购物车"中安装的不同语言中获取哪种语言处于活动状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在实时服务器上安装了多种语言(英语,杜克语,德语)的Opencart 1.5.4x并设置了主题. Opencart应用程序可以使用这些语言正常工作.

I have installed and themed Opencart 1.5.4x with multiple languages (English, Duch, German) on live server. Opencart application works properly with these languages.

当我单击语言链接并浏览整个网站时,该网站的内容已翻译成该语言,但是如何以编程方式找出哪种语言有效?

When I click on the language link and browse whole site, the content of the site is translated in this language, but how to find out, programatically, which language is active?

我需要向用户显示当前正在使用哪种语言.

I need to show the user which language is currently active.

推荐答案

我猜您应该在控制器或模型中调用$this->config->get('config_language_id');以获得当前活动语言的ID.

I guess You should call $this->config->get('config_language_id'); within a controller or model to get the ID of currently active language.

这意味着,如果您已经实现了自己的语言切换器,则在您的控制器中将语言设置为模板:

That means, if You have implemented Your own language switcher, in Your controller set the language to the template:

$this->data['active_language_id'] = $this->config->get('config_language_id');

,然后在您的模板中执行以下操作:

and then within Your template do something like:

<?php foreach($languages as $language) { ?>
<a href="..." class="lang-select <?php if $language['language_id'] == $active_language_id) echo ' active'; ?>"><?php echo $language['code']; ?></a>
<?php } ?>

我希望这是您需要解决的问题,并且对您有所帮助.

I hope this is what You need to solve and that it would help.

这篇关于在前端,如何在“打开购物车"中安装的不同语言中获取哪种语言处于活动状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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