-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[FrameworkBundle] Register an identity translator as fallback #28523
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
[FrameworkBundle] Register an identity translator as fallback #28523
Conversation
@@ -39,6 +43,10 @@ public function trans($id, array $parameters = array(), $domain = 'messages', $l | |||
*/ | |||
public function transChoice($id, $number, array $parameters = array(), $domain = 'messages', $locale = null) | |||
{ | |||
if (null === $this->translator) { | |||
return strtr($id, $parameters); |
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.
The plural rules should still be resolved here, the trait provided in contracts should be used for that purpose.
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.
OR remove strtr entirely as in #24358 !
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.
In fact, TwigBridge also needs the fix to handle plural, see #24514
ae03f59
to
43d20b1
Compare
Hi @yceruto, FYI, I pushed in your branch what I was talking in my comment a few hours ago. |
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.
43d20b1
to
5330f2d
Compare
Wow! thanks @nicolas-grekas, look very good to me. |
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! I like this a lot! Thanks Yonel.
Thank you @yceruto. |
…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 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 thetranslator
helper to be available.This change ensure that there will always be a
translator
helper whichas a fallback will just return the message key if no translator is present.