-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Translation] Message domains with dot not working #31400
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
Comments
I created a small sample project to reproduce this issue: https://github.com/jschaedl/symfony-issue-31400 The problem is that the FrameworkBundles Extension class loads the translation resources only if the filename contains two symfony/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php Line 1173 in ecfccc6
I don't see a reason why there is such a restriction. I think we can easily fix this and allow domain names with We need to adjust this line: symfony/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php Line 1173 in ecfccc6
and the
WDYT? |
…schaedl) This PR was merged into the 4.4 branch. Discussion ---------- [FrameworkBundle] Allow dots in translation domains | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no <!-- don't forget to update src/**/CHANGELOG.md files --> | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | #31400 <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | tbd. <!-- required for new features --> ### Description With this fix it is now possible to have `.` in translation domains like `app.security.en.yaml`. ### Todo - [x] add a test case Commits ------- 4b593b0 [FrameworkBundle] Allow dots in translation domains
Symfony version(s) affected: 4.2.x
Description
Translation message domains containing a dot (
.
) are not loaded, neither with nor without caching.How to reproduce
Create a translation in any controller or twig template using a message domain like
app.security
:Extracting translations with
php bin/console translation:update --dump-messages --force en
will correctly create the filetranslations/app.security.en.xlf
with thelogin.page.title
translation. But even arm -rf var/cache && php bin/console clear:cache
will never load this translation file.After spending hours with searching in the Symfony docs, Google and Stack Overflow I was sure that translation is configured correctly and must work. So I removed the message domain and the
translations/messages.en.xlf
got loaded. Then I tried another message domainsecurity
and theseucrity.en.xlf
got loaded as well. This lead me to the conclusion that there must be a bug with message domains containing a dot only, as further tests with dashed worked fine.Possible Solution
I could not locate where the bug happens because that might be in generated code and I don't know where this code is generated (some compiler passes possibly). So please, either fix this bug or if there is a reason why message domains must not contain dots document this clearly everywhere where message domains are mentioned (or link to Translation Component - Using Message Domains where it will be documented) including the why, because in my opinion the concept of Keyword Messages should not only be able to apply to message keys but message domains as well.
And if ti will not be supported, of course change the message extractor to report an error when it finds a message domain containing a dot instead of correctly generating the translation files.
The text was updated successfully, but these errors were encountered: