Skip to content

DataCollectorTranslator::getFallbackLocales() return empty array #23248

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

Closed
steevanb opened this issue Jun 21, 2017 · 8 comments
Closed

DataCollectorTranslator::getFallbackLocales() return empty array #23248

steevanb opened this issue Jun 21, 2017 · 8 comments

Comments

@steevanb
Copy link

steevanb commented Jun 21, 2017

Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version 3.2.9

Hi !

When i call $container->get('translator')->getFallbackLocales(), in dev environment, i get an empty array.
I have to call $container->get('translator.default')->getFallbackLocales() to really get fallback.

Problem is here : https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Translation/DataCollectorTranslator.php#L100
I have a LoggingTranslator instance, not Translator.
We can't change instanceof Translator by instanceof TranslatorInterface, cause TranslatorInterface do not define getFallbackLocales().

I don't know how to fix it ...

@xabbuh
Copy link
Member

xabbuh commented Jun 21, 2017

see #23250

@Hanmac
Copy link
Contributor

Hanmac commented Jun 21, 2017

hm i still don't see why it does look for specially Translator and why TranslatorInterface can't be extended to use getFallbackLocales :/

@chalasr
Copy link
Member

chalasr commented Jun 21, 2017

why TranslatorInterface can't be extended to use getFallbackLocales

@Hanmac Adding a new method to an interface would break any implementation that is not already implementing this method, adding a new interface extending the TranslatorInterface one is possible, but that needs to be discussed beforehand (in a dedicated issue) .

@xabbuh
Copy link
Member

xabbuh commented Jun 21, 2017

Adding a new method to an interface is a BC as all implementations would need to be adapted. That's why we cannot do so.

@steevanb
Copy link
Author

Thanks !

fabpot added a commit that referenced this issue Jun 21, 2017
…abbuh)

This PR was merged into the 2.7 branch.

Discussion
----------

[Translation] return fallback locales whenever possible

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #23248
| License       | MIT
| Doc PR        |

Commits
-------

3c21650 return fallback locales whenever possible
@fabpot fabpot closed this as completed Jun 21, 2017
@steevanb
Copy link
Author

Just a question : This PR was merged into the 2.7 branch., what about 2.8 et 3.x ?

@javiereguiluz
Copy link
Member

@steevanb from time to time we merge from lower branches to higher branches. So your PR will be merged "soon" to the upper branches too.

@steevanb
Copy link
Author

Ok, thanks !

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

No branches or pull requests

7 participants