【问题标题】:Error loading language on Code Igniter Rest Server在 Code Igniter Rest Server 上加载语言时出错
【发布时间】:2017-06-02 20:50:31
【问题描述】:

我正在用 Code Igniter 编写一个 API,我听取了很多人的建议来使用 Code Igniter Rest Server 库 (Git Repo)。我已按照开发人员指示的程序进行操作,但遇到了与语言加载相关的问题。据我所知,当我需要 REST_Controller.php 文件时会出现问题,并且在某些时候该脚本尝试加载语言文件并失败。问题是我把这个确切的文件放在应用程序和系统 language/english 目录中。在 config.php 我在语言会话中有这个:

$config['language'] = 'english';

这些是应用程序和系统的语言路径:

application/language/english/rest_controller_lang.php
system/language/english/rest_controller_lang.php

我仍然收到此错误:

无法加载请求的语言文件:language/english/rest_controller_lang.php

感谢有关如何解决此问题的任何提示。

【问题讨论】:

    标签: php rest api codeigniter


    【解决方案1】:

    我遇到了同样的问题并解决了。

    问题是codeigniter 找不到rest_controller 翻译。 你只需要创建这个文件/application/languages/english/rest_controller_lang.php

    然后把这段代码复制粘贴进去:

    <?php
    /*
     * English language
     */
    $lang['text_rest_invalid_api_key'] = 'Invalid API key %s'; // %s is the REST API key
    $lang['text_rest_invalid_credentials'] = 'Invalid credentials';
    $lang['text_rest_ip_denied'] = 'IP denied';
    $lang['text_rest_ip_unauthorized'] = 'IP unauthorized';
    $lang['text_rest_unauthorized'] = 'Unauthorized';
    $lang['text_rest_ajax_only'] = 'Only AJAX requests are allowed';
    $lang['text_rest_api_key_unauthorized'] = 'This API key does not have access to the requested controller';
    $lang['text_rest_api_key_permissions'] = 'This API key does not have enough permissions';
    $lang['text_rest_api_key_time_limit'] = 'This API key has reached the time limit for this method';
    $lang['text_rest_ip_address_time_limit'] = 'This IP Address has reached the time limit for this method';
    $lang['text_rest_unknown_method'] = 'Unknown method';
    $lang['text_rest_unsupported'] = 'Unsupported protocol';
    

    原始存储库: https://github.com/chriskacerguis/codeigniter-restserver/blob/master/application/language/english/rest_controller_lang.php

    如果你使用的是linux服务器,你可以像这样使用wget命令和git的行视图直接获取它,

    wget https://raw.githubusercontent.com/chriskacerguis/codeigniter-restserver/master/application/language/english/rest_controller_lang.php
    

    希望对你有帮助

    【讨论】:

      猜你喜欢
      • 2019-01-10
      • 2019-09-23
      • 2015-09-22
      • 2016-03-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-23
      • 1970-01-01
      相关资源
      最近更新 更多