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

Skip to content

[FrameworkBundle] Set only desired locales #31563

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
proArtex opened this issue May 21, 2019 · 3 comments
Closed

[FrameworkBundle] Set only desired locales #31563

proArtex opened this issue May 21, 2019 · 3 comments

Comments

@proArtex
Copy link

Description
There is no option to set locales that will be used in an app. FrameworkExtension is currently collect all the locales from different bundles (registerTranslatorConfiguration) and then it goes to Translator cache warmer. So I have many extra translations warmed up, but I want to use just a few. They are basically useless and take warmup time.

Example
So translation.yaml might contain available_locales directive:

framework:
    available_locales: ['en', 'fr']

and registerTranslatorConfiguration() function might restrict Finder to that locales.

@javiereguiluz
Copy link
Member

I think we should explore this idea. It's only a guess ... but the performance improvement should be noticeable because Symfony would track/parse fewer files and would created fewer catalog files.

@Pictor13
Copy link

Pictor13 commented Oct 24, 2019

I am having the same necessity.
There should be a way to define the locales available to the application.

Is there any progress on this?

What would be a workaround, for the moment, in order to limit the list of available locales?
Do we really need to uninstall the locales from the system, in order to hide them?
Or dunno if there's some intl build option to specify it 😕

@proArtex did you find any way to filter the usable locales?

@Pictor13
Copy link

For the moment I solved with a custom LanguageType/ChoiceType that gets the whole list of locales and filters them with a list of languages enabled on the app.
But I am curious if any native solution is on the way.

fabpot added a commit that referenced this issue Feb 4, 2020
… locales (javiereguiluz)

This PR was merged into the 5.1-dev branch.

Discussion
----------

[Translation] Introduce a way to configure the enabled locales

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

This implements the idea #31563 so we can decide if we want to add this or not. I tested it in the "Symfony Demo" app. Before: 107 catalogs created in cache/dev/translations/. After: 43 catalogs. But that's because the app is translated into lots of languages. In most cases, only 2 catalog files will be generated (vs 107 before).

If this idea is approved, I'll add tests and docs. Thanks.

Commits
-------

7658434 [Translation] Introduce a way to configure the enabled locales
@lyrixx lyrixx closed this as completed Feb 4, 2020
@nicolas-grekas nicolas-grekas modified the milestones: next, 5.1 May 5, 2020
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

6 participants