GitzJoey GitzJoey - 1 year ago 135
PHP Question

laravel language key from variable

Let's say I have this in

with this input

'testing.language.test' => 'testing'

then in the
I would like to consume it with this method
but not directly, instead I like to put it inside variable first then

$var = 'testing.language.test';
@lang('test' + $var);

but it's not working, it always returns the
without parsing it from the language file.

Answer Source

If you want to call it as a $var then do like so :

$var = 'testing.language.test';
{{Lang::get('test',[], $var )}}

And that means you are choosing a Locale from an array which is should be found in \Config\App.php file

'locale' => ['en' => 'English' ,'de'=>'Deutsch'],

And you can of course use Blade templating engine like so :

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download