Skip to content
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

Adding LexikTranslationBundle breaks translations from other bundles #440

Open
nicodemuz opened this issue Aug 17, 2023 · 3 comments
Open

Comments

@nicodemuz
Copy link

I was investigating for a long time how come some 3rd party translations do not work in my project. Turns out that LexikTranslationBundle somehow interferes with the translation loading by the default symfony installation.

For example, installing KnpTimeBundle works as expected when using it by itself. After introducing LexikTranslationBundle, the translations are no longer loaded.

When LexikTranslationBundle is moved as the first bundle in bundles.php, the translations are loaded correctly again.

I created a new public repository to demonstrate the issue, please see: https://github.com/nicodemuz/symfony-translation-test

This Symfony Slack thread may also be of interest: https://symfony-devs.slack.com/archives/C3EQ7S3MJ/p1692172721085889

@nicodemuz
Copy link
Author

nicodemuz commented Apr 11, 2024

Could the issue be that 3rd party bundle translations are being look'd up using wrong paths?

# KnpTimeBundle:
*** Using dir /path/to/symfony/vendor/knplabs/knp-time-bundle/Resources/translations to lookup translation files. ***
No file to import

There is no path such as:

/path/to/symfony/vendor/knplabs/knp-time-bundle/Resources/translations

The actual path is:

/path/to/symfony/vendor/knplabs/knp-time-bundle/translations

Does nobody else have this issue? @raziel057 @bartmcleod

@bartmcleod
Copy link
Collaborator

bartmcleod commented Feb 12, 2025

@nicodemuz I noticed today that the Lexik bundle indeed looks to export translations to Resources/translations in the project root, while nowadays, the translations live in {project root}/translations . I don't know how easy it is to fix and how it would affect existing solutions.

I saw that the config of a SF 7.03 project that I use for testing has configuration like this

framework:
    default_locale: en
    translator:
        default_path: '%kernel.project_dir%/translations'
        fallbacks:
            - en

lexik_translation:
    fallback_locale: en
    managed_locales: [en, nl]

I can imagine that if one would update the default_path that the framework to match the path that Lexik uses, it would also work well.

@nicodemuz
Copy link
Author

@bartmcleod The issue is not about project translations ('%kernel.project_dir%/translations'), the issue is with other 3rd party bundle translations.

For example, try using a 3rd party bundle (e.g. KnpTimeBundle) that uses translations together with this bundle (LexikTranslationBundle):
https://github.com/KnpLabs/KnpTimeBundle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants