简体   繁体   中英

Laravel - How to Clear cache of array language

I have a laravel application and I have two different languages. My problem is that I'm using queued emails and that just work with default language, so I try to add new keys and values to default language array to give me the possibility to use in both languages.

The problem is that don't recognise the new keys, makes me think that is a cache situation but I already clear the cache with artisan commands and continue the same.

Now I delete my messages.php inside my lang folder and It consider the older key yet. Is it cache? How can I solve that?

I put this in blade and works for default language:

@lang('messages.'. $months->month)

Next I add new keys to so I can translate to another language using the same default array language and do that:

@lang('messages.'. $months->month .'-en')

My array is like that:

'Março' => 'Março', 
'Março-en' => 'March',

but it just recognise the first key.

Thank you

缓存在队列中的语言文件,您只需要像这样重新启动队列:

php artisan queue:restart

I ran into a similar situation in a project I was working on. The issue in my case was that I was assuming that the PHP localization definitions (ex: resources/lang/en/auth.php) were going to be used when performing translations using the __() function.

As it turns out though, when somebody set this project up, they did so in a way that would be able to share out the translations with the front-end. In order to do so, this person had set up a new artisan command that would compile JSON equivalents of those PHP localization definitions. Unfortunately, when they did that, they chose to use the same folder/filenames that Laravel will use too (ex: resources/lang/en.json).

Because of the fact that this had been done, Laravel was reading from these JSON files instead of the PHP files whenever I used the __() function. This meant that changes would only ever be reflected if I first deleted those JSON files, and then rebuilt them.

Ultimately, I ended up updating the script that builds those JSON files. Now they're created with different names so there is no conflict.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM