So I am trying to show text in a select of a form in HTML depending of the language of the user, I am using Laravel and I have a simple way to do it:
Lang::get('texts.whatever');
That goes to texts.php file that changes 'whatever' for a proper text.
Besides, I have an associative array like this: $dropdown = ['1'=>'France','2'=>'Germany', '3'=>'Greece', '4'=>'Portugal', '5'=>'Spain', '6'=>'United Kingdom'];
And something like this:
@foreach($dropdown as $id=>$name)
<?php
$newArray[$id]=Lang::get('texts.'.$name);
?>
@endforeach
<?php
$dropdown = $newArray;
?>
After that, I use $dropdown in my select of the form and it shows texts plus whatever it is in $name. It does not "get" the text in texts.php. However, if I change 'texts.'.$name to 'texts.yeah' (for example) it fills the select properly.
I tried eval(), exec(), etc. and I don't know what else to do. Maybe I am not using them right.
Any tips or advice? Thank you in advance.