doty58493 2014-07-10 17:23
浏览 35
已采纳

Codeigniter DB语言扩展无法正常工作

I'm trying to use this extension

But it gives me the following error when loading the library:

Unable to load the requested class: Language

Also if I write MY_Language instead, it gives me the following error:

Fatal error: Class 'CI_Language' not found in C:\wamp\www\ckphp\application\libraries\MY_Language.php on line 79

I am using WAMP and CI v. 2.2.0

Thanks!

  • 写回答

2条回答 默认 最新

  • duanouyong4228 2014-07-15 09:11
    关注

    I figured it out myself after some more researching...

    Apparently the language class is not even in the library folder, but in core folder, meaning it should be placed in the core application/core folder. Also the name is not CI_Language, but CI_Lang, meaning the file name has to be MY_Lang (if MY_ is your prefix). The last thing to change in the extension is

    parent::CI_Language();

    to

    parent::__construct();

    and everything should work fine!

    Usage:

    $this->lang->load('set', 'language'); // To load a language
    $this->lang->line('key'); // to display the text
    

    or simply

    lang('key'); // if using the language helper
    

    Hope this will help others in the future!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 蓝桥oj3931,请问我错在哪里
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染