Call to protected method CodeIgniter\Language\Language::load() from scope CodeIgniter |
Hi,
to load translation-files and create some dynamic content, i add the language service to the _construct of my own library. Code: "function __construct(){ ... $this->lang = service('language');" ... }" Now i want to load a language file by calling my lib inside a view-file in this way Code: "$ci->mytools->lang->load(filepath', $ci->mytools->request->getLocale(),true)" The result is the error message: "Call to protected method CodeIgniter\Language\Language::load() from scope CodeIgniter\View\View" What i do wrong - how i cann load a language file on each point i want?
No way, this is a system method. You can replace service('language') in Config/Services.php and add the desired methods.
https://github.com/codeigniter4/CodeIgni...e.php#L237
Where are you getting the $ci from this looks like CodeIgniter 3 code.
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
Do you want to load the whole file to be used in a view or are you looking to use language specific strings in your view?
The most obvious way to use a language string is something like this: PHP Code: <?= lang('General.Actions') ?> Where there is an existing file in the Language/en folder with the name 'General.php'. Content would be: PHP Code: <?php |
Welcome Guest, Not a member yet? Register Sign In |