Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Translation] TransChoice invalid plural translation #31110

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

Simperfit
Copy link
Contributor

@Simperfit Simperfit commented Apr 15, 2019

Q A
Branch? 4.4
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #27401
License MIT
Doc PR symfony/symfony-docs#11425

src/Symfony/Contracts/Translation/TranslatorTrait.php Outdated Show resolved Hide resolved
@Simperfit Simperfit force-pushed the feature/allow-to-not-throw-when-using-trans-and-transchoice branch from f979dea to 9c13ce2 Compare April 15, 2019 05:36
src/Symfony/Contracts/Translation/TranslatorTrait.php Outdated Show resolved Hide resolved
src/Symfony/Component/Translation/IdentityTranslator.php Outdated Show resolved Hide resolved
src/Symfony/Component/Translation/IdentityTranslator.php Outdated Show resolved Hide resolved
src/Symfony/Contracts/Translation/TranslatorTrait.php Outdated Show resolved Hide resolved
@stof
Copy link
Member

stof commented Apr 15, 2019

and this does not solve the similar issue when using the ICU format (MessageFormatter also throws for invalid pluralization)

@Simperfit Simperfit force-pushed the feature/allow-to-not-throw-when-using-trans-and-transchoice branch from 9c13ce2 to 8a87162 Compare April 15, 2019 17:59
@Simperfit
Copy link
Contributor Author

First of all thanks @ro0NL and @nicolas-grekas for the review, I'm working on this right now and wanted to know what we should return, an empty string ?

Do we update all the translation components (such as TranslationExtension, MessageFormatter) or do we only do that on the transChoice of the IdentityTranslator so we are strictly following the issue. (that's what I've done right now, tell me if we want to go further.

@Simperfit Simperfit force-pushed the feature/allow-to-not-throw-when-using-trans-and-transchoice branch from 8a87162 to 0aa48c2 Compare April 15, 2019 18:04
Copy link
Contributor

@ro0NL ro0NL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what we should return

the default behavior?

return strtr($id, $parameters);

@@ -10,7 +10,9 @@
<service id="Symfony\Component\Translation\TranslatorInterface" alias="translator" />
Copy link
Contributor

@ro0NL ro0NL Apr 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the default identity translator above this one should be updated as well.. might even be a public alias to identity_translator 🤔

src/Symfony/Component/Translation/IdentityTranslator.php Outdated Show resolved Hide resolved
src/Symfony/Component/Translation/IdentityTranslator.php Outdated Show resolved Hide resolved
src/Symfony/Component/Translation/IdentityTranslator.php Outdated Show resolved Hide resolved
src/Symfony/Component/Translation/IdentityTranslator.php Outdated Show resolved Hide resolved
@ro0NL
Copy link
Contributor

ro0NL commented Apr 16, 2019

last but not least; trans() (derived from the trait) might still throw in case of a plural message ... should we use it as doTrans, and try/catch it as well in IdentityTranslator::trans()? Not sure if that's what @stof meant...

@Simperfit
Copy link
Contributor Author

@ro0NL I don't know, I think it could be on the user at this point.

@Simperfit Simperfit force-pushed the feature/allow-to-not-throw-when-using-trans-and-transchoice branch from 0aa48c2 to a7fef52 Compare April 22, 2019 06:15
Copy link
Contributor

@ro0NL ro0NL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Simperfit isnt it weird transChoice is "debug-able" whereas trans() is not? Esp. since transChoice is deprecated.. so $debug is useless in 5.0?

Moreover, what to do with

$translator = new class() implements TranslatorInterface, LocaleAwareInterface {
use TranslatorTrait;
};
should it be "debug aware" also?

src/Symfony/Component/Translation/IdentityTranslator.php Outdated Show resolved Hide resolved
@stof
Copy link
Member

stof commented Apr 23, 2019

trans can throw in 2 cases:

@Simperfit
Copy link
Contributor Author

So what to do here ? Do we need to not throw and pass the debug directly in the trans method ?
Or in all caller ? cc @nicolas-grekas

@Simperfit Simperfit force-pushed the feature/allow-to-not-throw-when-using-trans-and-transchoice branch 2 times, most recently from 8a3fdb5 to 1ee08d4 Compare April 23, 2019 18:07
@Simperfit Simperfit force-pushed the feature/allow-to-not-throw-when-using-trans-and-transchoice branch from 1ee08d4 to c7f5cf7 Compare May 18, 2019 05:53
@Simperfit
Copy link
Contributor Author

I like how it's working right now @stof @nicolas-grekas tell me if I need to change something.

@Simperfit
Copy link
Contributor Author

Status: Needs Review

Copy link
Member

@xabbuh xabbuh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to update other usage of the TranslatorTrait (in Symfony\Bridge\Twig\Extension\TranslationExtension and Symfony\Component\Validator\ValidatorBuilder) too?

And we need to mark any version of the Translation component as conflicting with the FrameworkBundle.

@Simperfit Simperfit force-pushed the feature/allow-to-not-throw-when-using-trans-and-transchoice branch from 0732cc5 to c3d6800 Compare June 21, 2019 21:08
@Simperfit
Copy link
Contributor Author

Do we need to update other usage of the TranslatorTrait (in Symfony\Bridge\Twig\Extension \TranslationExtension and Symfony\Component\Validator\ValidatorBuilder) too?

I don't know, maybe @ro0NL has some thoughts on this ?

@javiereguiluz javiereguiluz changed the title [Translation] TransChoice invalide plural translation [Translation] TransChoice invalid plural translation Jul 12, 2019
@Simperfit Simperfit force-pushed the feature/allow-to-not-throw-when-using-trans-and-transchoice branch from c3d6800 to 1669eab Compare July 17, 2019 19:17
@Simperfit
Copy link
Contributor Author

Status: Needs Review

@Simperfit
Copy link
Contributor Author

cc @xabbuh

@nicolas-grekas
Copy link
Member

A test case would be nice please (+rebase needed)

@Simperfit Simperfit force-pushed the feature/allow-to-not-throw-when-using-trans-and-transchoice branch from 1669eab to 47d6d7e Compare August 14, 2019 05:38
@nicolas-grekas nicolas-grekas modified the milestones: next, 4.4 Oct 27, 2019
@noniagriconomie
Copy link
Contributor

It will be very cool to have it in 4.4 as a bug fix, but i fear it will not be considered as it
so sadly 5.X

thank you working on this @Simperfit :)

@nicolas-grekas nicolas-grekas force-pushed the feature/allow-to-not-throw-when-using-trans-and-transchoice branch from 47d6d7e to 5c5420b Compare February 3, 2020 11:18
@nicolas-grekas
Copy link
Member

Closing as this staled.
If you want to take over @noniagriconomie, this should be for master.

@noniagriconomie
Copy link
Contributor

@nicolas-grekas hello
what do you mean by take over? finishing the review you left?
Yes i will do it for sure to continue @Simperfit works 👍

@nicolas-grekas
Copy link
Member

I fixed all comments before closing so yes, this should be good to go on master, but with enough description in the PR to be able to understand the use case and that could act as the start of a documentation.

@noniagriconomie
Copy link
Contributor

@nicolas-grekas related to #28375
can you confirm that this code is now useless for sf5+ ?

and as this is not considered as a bugfix, IMO sf 3 and 4 can not benefit this

thank you

@nicolas-grekas
Copy link
Member

I don't know :)

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.

8 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.