Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[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

Merged
merged 1 commit into from
Sep 21, 2018

Conversation

yceruto
Copy link
Member

@yceruto yceruto commented Sep 19, 2018

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.

@@ -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);
Copy link
Member

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.

Copy link
Member

@nicolas-grekas nicolas-grekas Sep 20, 2018

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 !

Copy link
Member

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

@nicolas-grekas
Copy link
Member

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.
@yceruto
Copy link
Member Author

yceruto commented Sep 20, 2018

Wow! thanks @nicolas-grekas, look very good to me.

@nicolas-grekas nicolas-grekas added this to the next milestone Sep 20, 2018
Copy link
Member

@javiereguiluz javiereguiluz left a 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.

@nicolas-grekas
Copy link
Member

Thank you @yceruto.

@nicolas-grekas nicolas-grekas merged commit 5330f2d into symfony:master Sep 21, 2018
nicolas-grekas added a commit that referenced this pull request Sep 21, 2018
…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
@yceruto yceruto deleted the php-identity-translator branch September 21, 2018 11:06
Nyholm added a commit to Nyholm/symfony that referenced this pull request Sep 22, 2018
@nicolas-grekas nicolas-grekas modified the milestones: next, 4.2 Nov 1, 2018
This was referenced Nov 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants