Skip to content

[RFC][Translation] Deprecate resource_files in translator #32735

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
wants to merge 1 commit into from

Conversation

pierredup
Copy link
Contributor

@pierredup pierredup commented Jul 25, 2019

Q A
Branch? 4.4
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? yes
Tests pass? yes
Fixed tickets #32708 (comment)
License MIT
Doc PR TBD

The list of resource files is cached by the container at compile time. This means that any change in translation files (adding/removing a file) needs a rebuilt container t take effect.
This PR proposes to deprecate this behaviour and let the translator manage its own resources fully.

This approach is to pass a list of directories to the translator instead, which the translator can use to determine if the cache needs to be rebuilt. Any change in the directories means only the translator cache will be rebuilt while the container cache stays untouched.

The only time the container needs to be rebuilt is when a new translation directory is added (E.G when adding a new bundle).

I'm not 100% sure what effect this will have on 3rd-party bundles (I.E if a bundle explicitly requires this behaviour and can't pass directories instead), so any insights would be appreciated.

@carsonbot carsonbot added Status: Needs Review RFC RFC = Request For Comments (proposals about features that you want to be discussed) Translation Feature Deprecation labels Jul 25, 2019
@pierredup pierredup force-pushed the translation-paths branch from cc6d324 to f00c4b4 Compare July 25, 2019 08:24
/**
* @dataProvider getDebugModeAndCacheDirCombinations
* @group legacy
*/
public function testResourceFilesOptionLoadsBeforeOtherAddedResources($debug, $enableCache)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

With these changes, the following option is now unsupported

'resource_files' => ['some_locale' => ['messages.some_locale.loader']]

so a work-around will be needed for this scenario (Maybe adding a new option set loaders per locale?)

/**
* Constructor.
*
* Available options:
*
* * cache_dir: The cache directory (or null to disable caching)
* * debug: Whether to enable debugging or not (false by default)
* * resource_files: List of translation resources available grouped by locale.
Copy link
Member

Choose a reason for hiding this comment

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

the new option should be added

@stof
Copy link
Member

stof commented Jul 25, 2019

I know for sure that this will impact https://github.com/willdurand/BazingaJsTranslationBundle, which inspects the definition of the translator service to get the list of resources for its translation finder. The new logic would force the bundle to duplicate the whole location of file resources (maybe this indicates a need for a new service in core, so that they can use the same service than the translator rather than duplicating some internal logic).

@nicolas-grekas nicolas-grekas added this to the next milestone Jul 26, 2019
@nicolas-grekas
Copy link
Member

BazingaJsTranslationBundle inspects the definition of the translator service to get the list of resources for its translation finder

Then we should ensure the new logic exposes a way to get the list of resources from the translator cache. @pierredup do you think it possible?

@fabpot
Copy link
Member

fabpot commented Feb 3, 2020

Closing as there is no more activities on this PR (and it cannot be merged as is). Fee free to reopen if you want to finish it.

@fabpot fabpot closed this Feb 3, 2020
@nicolas-grekas nicolas-grekas modified the milestones: next, 5.1 May 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Deprecation Feature RFC RFC = Request For Comments (proposals about features that you want to be discussed) Status: Needs Review Translation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants