-
Notifications
You must be signed in to change notification settings - Fork 267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error loading translations from database #388
Comments
Adding |
@nithiz I sat down to fix this, but I realized you haven't described what you were trying to do. When do you see the error? |
@bartmcleod I'm seeing the error on page load. |
@nithiz It might be the Symfony version then. I tested against SF 5.2. Any specific page where this happens? I have no routes in my Symfony app. Can you pin it down to the exact call in your code that precedes the error? |
@bartmcleod It's really hard to figure out where exactly it goes wrong. By default the dispatched GetDatabaseResourcesEvent event is never really fired in build time causing the resources to be empty. I'm running symfony 5.1.7 with php 7.4. I'm using Sulu as a CMS which uses a modified public/index.php but i don't think that is causing an issue. It's not any specific page as the error is triggered in build time. Even running bin/console will trigger the error. As a workaround i'm simply using my own Translator class and stripped out all caching:
I added my stacktrace, it might help you figure out where it goes wrong.
|
@nithiz Sorry for my late reply. I remember encountering this issue, but I fixed it. So could it be something old is stuck in your config cache or in some custom configuration? I remember that I had to change quite a bit in the configuration to make this error go away and have the resources loaded. |
Hi @bartmcleod, do you remember what config file you changed ? As explained by another user the error comes from foreach ($resources as $resource) {
$this->addResource('database', 'DB', $resource['locale'], $resource['domain']);
} This is the dump from Thanks in advance |
Hi @jawira, sorry, I don't remember. I had to step through it with the debugger to find the culprit is all I remember |
Quite an old 'bug' but for me it was caused / resolved because database entries in lexik_trans_unit didn't had a corresponding value in lexik_trans_unit_translations |
@tmzwinkels thank you, this fixed it for me on Symfony 5.4 and TranslationBundle 5.2. |
Hello |
Hi,
When using the newest 5.0.2 package i get an
Warning: Invalid argument supplied for foreach()
error onTranslation/Translator.php (line 33)
. It seems that theGetDatabaseResourcesListener
is never fired and$event->getResources()
is always null. I'm using the minimal configuration.This is on Symfony 5.1.7.
Any ideas?
The text was updated successfully, but these errors were encountered: