gpt4 book ai didi

arrays - 使 Codeigniter 网站多语言化的最佳方法。从 lang 数组调用取决于 lang session ?

转载 作者:行者123 更新时间:2023-12-03 05:12:28 25 4
gpt4 key购买 nike

我正在研究时间和时间,但我找不到任何清晰、有效的方法来实现它:/

我有一个英文版的 codeigniter 基础网站,现在我必须添加波兰语。根据访问者的选择将我的网站设置为两种语言的最佳方法是什么?

有没有办法为每种语言创建数组文件,并根据语言选择中的 session 在 View 文件中调用它们?我不想使用数据库。

感谢帮助!我的截止日期快到了:/谢谢!!

最佳答案

你见过CodeIgniter's Language library吗? ?

The Language Class provides functions to retrieve language files and lines of text for purposes of internationalization.

In your CodeIgniter system folder you'll find one called language containing sets of language files. You can create your own language files as needed in order to display error and other messages in other languages.

Language files are typically stored in your system/language directory. Alternately you can create a folder called language inside your application folder and store them there. CodeIgniter will look first in your application/language directory. If the directory does not exist or the specified language is not located there CI will instead look in your global system/language folder.

就你而言...

  • 您需要创建一个 polish_lang.phpenglish_lang.php里面application/language/polish
  • 然后在该文件中创建 key (例如 $lang['hello'] = "Witaj";
  • 然后将其加载到您的 Controller 中,例如 $this->lang->load('polish_lang', 'polish');
  • 然后获取像 $this->lang->line('hello'); 这样的行只需将此函数的返回值存储在变量中,以便您可以在 View 中使用它。

对英语和您需要的所有其他语言重复这些步骤。

关于arrays - 使 Codeigniter 网站多语言化的最佳方法。从 lang 数组调用取决于 lang session ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1328420/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com