-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[TwigBundle] register an identity translator as fallback #24358
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
Conversation
The Form component can be used without the Translation component. However, to be able to use the default form themes provided by the TwigBridge you need to have the `trans` filter to be available. This change ensure that there will always be a `trans` filter which as a fallback will just return the message key if no translator is present.
#24303 already improved the situation when running |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent as so simple!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really nice! Thanks.
Thank you @xabbuh. |
…ck (xabbuh) This PR was merged into the 3.4 branch. Discussion ---------- [TwigBundle] register an identity translator as fallback | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #24303 (comment) | License | MIT | Doc PR | The Form component can be used without the Translation component. However, to be able to use the default form themes provided by the TwigBridge you need to have the `trans` filter to be available. This change ensure that there will always be a `trans` filter which as a fallback will just return the message key if no translator is present. Commits ------- f0876e5 register an identity translator as fallback
@@ -94,11 +94,19 @@ public function getTranslationNodeVisitor() | |||
|
|||
public function trans($message, array $arguments = array(), $domain = null, $locale = null) | |||
{ | |||
if (null === $this->translator) { | |||
return $message; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should still replace arguments IMO. Otherwise this does not work even for the case where the English message is the source
…or (xabbuh) This PR was merged into the 3.4 branch. Discussion ---------- [TwigBridge] replace parameters in dummy identity translator | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #24358 (comment) | License | MIT | Doc PR | Commits ------- 2c9c3d8 replace parameters in dummy identity translator
This PR was merged into the 3.4 branch. Discussion ---------- [Bridge\Twig] Lazy-load deps | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Spotted while benching a HelloWorld and comparing v3.3 to v4.0. At this micro-bench level, even registering one more twig extension makes a difference (here, it's `TranslationExtension`, after #24358) Commits ------- 3fc766f [Bridge\Twig] Lazy-load deps
…allback (yceruto) This PR was merged into the 4.2-dev branch. Discussion ---------- [FrameworkBundle] Register an identity translator as fallback | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #27589 | License | MIT | Doc PR | - The same approach as symfony/symfony#24358, suggested by @xabbuh here symfony/symfony#27589 (comment) **Templating Engine Context** The Form component can be used without the Translation component. However, to be able to use the default form themes provided by the `FrameworkBundle` you need to have the `translator` helper to be available. This change ensure that there will always be a `translator` helper which as a fallback will just return the message key if no translator is present. Commits ------- 5330f2d017 [FrameworkBundle] Register an identity translator as fallback
…allback (yceruto) This PR was merged into the 4.2-dev branch. Discussion ---------- [FrameworkBundle] Register an identity translator as fallback | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #27589 | License | MIT | Doc PR | - The same approach as #24358, suggested by @xabbuh here #27589 (comment) **Templating Engine Context** The Form component can be used without the Translation component. However, to be able to use the default form themes provided by the `FrameworkBundle` you need to have the `translator` helper to be available. This change ensure that there will always be a `translator` helper which as a fallback will just return the message key if no translator is present. Commits ------- 5330f2d [FrameworkBundle] Register an identity translator as fallback
The Form component can be used without the Translation component.
However, to be able to use the default form themes provided by the
TwigBridge you need to have the
trans
filter to be available.This change ensures that there will always be a
trans
filter which asa fallback will just return the message key if no translator is present.