-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Form Class translation extraction #35082
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
@javiereguiluz is this a new feature? Isn't that supported yet? |
It's indeed a known limitation that extraction from form labels is not possible. That will be a new feature. |
This blog says it is supported... not a new feature. |
I don't see anything in the blog post talking about the extraction of translations. |
Yes, it's only about using variables in labels and helpers. |
That's probably because writing the code to extract the translations is a harder task. But if you would like to work on it, I will happily review a PR implementing this task. :) |
Pretty sure this was working beforehand and it's not a feature but a bug ? In a FormType:
Used to work, but not anymore. It's supposed to as per documentation: https://symfony.com/doc/current/reference/forms/types/form.html#label-translation-parameters Those strings are not extracted anymore. But maybe I dreamt and those strings were never extracted to begin with! |
@Pixelshaped The documentation you linked to does not talk about the extraction of translations. It just shows how you can translate the label. |
You're right. I think what mislead me was the debug toolbar reporting the right translation domain for the form once configured in configureOptions. |
now with #37670 merged, we could think of |
Out of curiosity I tried to get the PhpExtractor to handle FormTypes but adding the path to twig setup. twig:
default_path: '%kernel.project_dir%/templates'
paths:
'%kernel.project_dir%/src/Form': ~ Using Maybe pointing PhpExtractor to FormTypes could make it into 5.2? |
It's not easy to detect where to look for new translations. Maybe this should be a particular decision per case. A new option in related commands could help with this need:
For the record: this PR #40229 was open to add the whole src/. |
… from all of src (natewiebe13) This PR was squashed before being merged into the 5.3-dev branch. Discussion ---------- [FrameworkBundle][Translation] Extract translation IDs from all of src | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | Related to #39126 possibly #35082 as well | License | MIT | Doc PR | TBD This PR allows extracting (`bin/console translation:update`) and debugging (`bin/console debug:translation`) translations using Translatable messages. Currently we only check classes that include the `TranslatorInterface`, but this no longer covers all instances of this. Current considerations: - Should this be treated as a bug fix or a new feature? On one hand, text extraction would no longer work if moving to TranslatableMessages (like we're doing) on the other, it wasn't intended to search all PHP files. As a bug fix would get this into Symfony faster, as a feature would mean having to wait until 5.3 is released. - Is there a better way to get the source directory that doesn't involve hardcoding `/src`? - Adding this in on a project with ~12k LOC in `/src` takes these operations from about 3s to 5s, but I feel like this is reasonable considering this command isn't likely called constantly. I can provide more accurate stats as requested. Commits ------- b02ae50 [FrameworkBundle][Translation] Extract translation IDs from all of src
This is a hack to scan froms for translation while waiting for symfony/symfony#40229 to be released. See symfony/symfony#35082 (comment)
This is a hack to scan froms for translation while waiting for symfony/symfony#40229 to be released. See symfony/symfony#35082 (comment)
Thank you for this suggestion. |
Could I get a reply or should I close this? |
Hey, I didn't hear anything so I'm going to close it. Feel free to comment if this is still relevant, I can always reopen! |
Symfony version(s) affected: 4.4.2 and 5.0.2
Description
Labels defined in a Form Class are not extracted to translation file
How to reproduce
Download symfony/demo, remove translation files, run
search for translation "label.tags". It is defined in Form/PostType as label, but it is missing now in the translation file.
The text was updated successfully, but these errors were encountered: