Skip to content
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

[5.4] Replace symfony's translator #15563

Merged
merged 2 commits into from
Sep 23, 2016
Merged

[5.4] Replace symfony's translator #15563

merged 2 commits into from
Sep 23, 2016

Conversation

themsaid
Copy link
Member

Laravel uses its own Translator in most of the situations, the only part where we use Symfony's translator is in trans_choice().

This PR adds a replacement to the MessageSelector class used in trans_choice() and removes all instances of Symfony's translator from the code base.

The new MessageSelector supports the same basic functionality supported by Symfony's with some slight changes to the syntax:

  • [1,Inf] is now [1,*]
  • Added support for [*,5]
  • Removed one:one record|many: many records support, it'll match in this order by default.

@kamui545
Copy link
Contributor

Hey nice work, it reminds me of an issue I opened last year.

#9584

I think you can also remove the $domain param from the helper functions as I stated on the previous issue.

@themsaid
Copy link
Member Author

@kamui545 yeah good catch, updated :)
Thanks

@garygreen
Copy link
Contributor

Looks awesome, nice work 😄

@Skysplit
Copy link

Skysplit commented Sep 23, 2016

I think that translator contract should also implement has and get methods. get is being used in Validator.php and as we do not rely on implemenation, but interface, we should actually use only methods that are provided by interface. has would be just nice addition to get.

@taylorotwell taylorotwell merged commit 5ff36c6 into laravel:master Sep 23, 2016
@cjmaxik
Copy link

cjmaxik commented Feb 6, 2017

So, all plural rules from https://github.com/symfony/translation/blob/master/PluralizationRules.php isn't applicable now. Most of the translations are broken. Thanks...

@kamui545
Copy link
Contributor

kamui545 commented Feb 6, 2017

@cjmaxik Could you provide a way to reproduce your issue? That would be helpful.

@cjmaxik
Copy link

cjmaxik commented Feb 6, 2017

en

'apples' => ':count apple|:count apples',

1 apple | 2 apples | 24 apples | 2657 apples

ru

'apples' => ':count яблоко|:count яблока|:count яблок',

Should be 1 яблоко | 2 яблока | 24 яблока | 2657 яблок
Returns 1 яблоко | 2 яблока | 24 яблока | 2657 яблока

There is more plural rules then one|many.

@symbios-zi
Copy link

symbios-zi commented Feb 6, 2017

@themsaid Why did you break plurals for Russian language? I guess not the only Russian plurals were broken.
Please look at https://github.com/symfony/translation/blob/master/PluralizationRules.php

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants