5

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

user3242861
  • 1,839
  • 12
  • 48
  • 93

2 Answers2

1

The language files cached in a queue, all you need is to restart queue like so:

php artisan queue:restart
Yevgeniy Afanasyev
  • 37,872
  • 26
  • 173
  • 191
1

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.