Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel string Localization in config files

I'm having problem using trans() function in config file, I feel it not supposed to be used that way. However I've no clue on what would be the most efficient way to translate string text in config files (files in /config folder).

Original code

<?php

return [
    'daily' => 'Daily'
];

When I try to implement trans() application crashes and laravel return white page without any error messages

<?php

return [
    'daily' => trans('app.daily_text')
];
like image 740
Ittikorn S. Avatar asked Dec 03 '22 15:12

Ittikorn S.


1 Answers

The config files are one of the first stuff Laravel initialize, it means you can't use Translator nor UrlGenerator inside a config file.

I don't know what you are trying to do, but you shouldn't need to use Translator inside a config file though...

like image 111
Elie Faës Avatar answered Dec 06 '22 09:12

Elie Faës