Welcome Guest, Not a member yet? Register   Sign In
Load language array
#5

(This post was last modified: 11-16-2020, 09:13 AM by henry_miaomiao.)

(11-16-2020, 07:20 AM)T.O.M. Wrote: I also was interested of this question here but did not find the answer.
So I've decided do not load all translations in controller. I just output translations in view:

PHP Code:
<div><?= lang('file_lang.t1'?></div>
<div><?= lang('file_lang.t2'?></div> 

All translations are displayed in the language (locale) specified in the request. So you need to change locale in the request (if you don't do it) with $this->request->setLocale($locale) - in Controller or in Filter.

There were a very symple function in CI 2...

$data['menu'] = $this->lang->load('menu');

Why there isn't a simil function?

Here the solution:

Add: return $lang; at the end of array in the file_lang.php

Now it's working
Reply


Messages In This Thread
Load language array - by henry_miaomiao - 11-16-2020, 04:41 AM
RE: Load language array - by InsiteFX - 11-16-2020, 06:28 AM
RE: Load language array - by henry_miaomiao - 11-16-2020, 06:36 AM
RE: Load language array - by T.O.M. - 11-16-2020, 07:20 AM
RE: Load language array - by henry_miaomiao - 11-16-2020, 08:13 AM
RE: Load language array - by InsiteFX - 11-16-2020, 01:00 PM



Theme © iAndrew 2016 - Forum software by © MyBB