CodeIgniter的国际化(i18n)库如何使用下拉列表设置langugage [英] Internationalization (i18n) library for CodeIgniter how to set langugage with dropdown lis

查看:76
本文介绍了CodeIgniter的国际化(i18n)库如何使用下拉列表设置langugage的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!



我使用Codeigniter(i18n)库来国际化我的网站。

我想制作一个视图文件这样的语言的下拉列表。

用户可以选择一种语言。

如何通过所选元素值为主控制器设置语言。

(如何添加url所选元素的值,如http:// localhost / multilang / de)



我有一个Ajax.js我可以通过邮寄方式将其发送给控制器。

 <  选择 >  
< 选项 value = en > 英文< / option >
< 选项 = fr > 法语< / option >
< 选项 value = hu > 匈牙利语< / option >
< 选项 value = ro > 罗马尼亚语< / option >
< / select >
(我很抱歉我的英语不好。)

解决方案

 <  选择 >  
< 选项 value = zh > Eng lish < / option >
< 选项 value = fr SELECTED > 法语< / option > < ;! - 这将被选中 - >
< 选项 value = hu > 匈牙利语< / option >
< < span class =code-leadattribute>选项 value = ro > 罗马尼亚语< / option >
< / select >





如果你想用javascript更改所选值,代码很简单:

  document  .getElementById('  SelectObjectId')。value = '  hu'; 


Hi Everyone!

I used the Codeigniter (i18n) library to internationalization my site.
I wanna make a view file with a dropdown list with languages like this.
The user can select a language.
How can i set language with the main controller by the selected element value.
(How to add the url the selected element’s value like this "http://localhost/multilang/de")

I have an Ajax.js with i can get the selected elemenet, and i can send it to controller by post.

<select>
  <option value="en">English</option>
  <option value="fr">French</option>
  <option value="hu">Hungarian</option>
  <option value="ro">Romanian</option>
</select>
( I am sorry for my bad English.)

解决方案

<select>
  <option value="en">English</option>
  <option value="fr" SELECTED>French</option><!--this will be selected-->
  <option value="hu">Hungarian</option>
  <option value="ro">Romanian</option>
</select>



if you want to change selected value using javascript the the code is simple:

document.getElementById('SelectObjectId').value='hu';


这篇关于CodeIgniter的国际化(i18n)库如何使用下拉列表设置langugage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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