Skip to content

Move the TranslationLoader to the Translation component. #23666

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 8 commits into from

Conversation

Nyholm
Copy link
Member

@Nyholm Nyholm commented Jul 25, 2017

Q A
Branch? 3.4
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? yes
Tests pass? yes
Fixed tickets
License MIT
Doc PR

Move the TranslationLoader away from the FrameworkBundle and to the Translation component where it belongs. Im not sure why it was put here in the first place. My guess is that we wanted to avoid adding Finder as a dependency in the Translation component.

Btw, this is me making this suggestion very politely. I think it makes sense since third party libraries should not be forced to require all FrameworkBundle for this class.

@Nyholm
Copy link
Member Author

Nyholm commented Jul 25, 2017

Not sure why the "deps high" test is failing. Should I split this into two PRs?

@chalasr
Copy link
Member

chalasr commented Jul 25, 2017

it fails because it runs on master for which the class does not exist yet (it's ok).

@nicolas-grekas nicolas-grekas added this to the 3.4 milestone Jul 26, 2017
@@ -37,6 +37,9 @@ FrameworkBundle
* The `--no-prefix` option of the `translation:update` command is deprecated and
will be removed in 4.0. Use the `--prefix` option with an empty string as value
instead (e.g. `--prefix=""`)

* The class `Symfony\Bundle\FrameworkBundle\Translation\TranslationLoader` was
moved to the Translation component (`Symfony\Component\Translation\Loader\TranslationLoader`)
Copy link
Member

Choose a reason for hiding this comment

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

You need to also add a note in the CHANGELOG for 4.0.

@javiereguiluz
Copy link
Member

Not sure if it's really needed, but you can easily remove the Finder dependency because the code using it is trivial. It's a matter of making a single glob() call.

@Nyholm
Copy link
Member Author

Nyholm commented Jul 26, 2017

Thank you for the reviews. I've updated accordingly.

@javiereguiluz I prefer to leave it as it is. The Finder dependency is not large and I may have more PRs later that depend on Finder.

*/
class TranslationLoader
class TranslationLoader extends \Symfony\Component\Translation\Loader\TranslationLoader
Copy link
Member

Choose a reason for hiding this comment

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

You should add a deprecation notice when this class is used.

Copy link
Member

Choose a reason for hiding this comment

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

And internal usages of this class should be changed to use the new class instead (which could lead to some composer dep changes in frameworkbundle probably)

$catalogue->addCatalogue($loader->load($file->getPathname(), $catalogue->getLocale(), $domain));
}
}
@trigger_error(sprintf('The class "%s" has been deprecated. Use "%s" instead. ', self::class, \Symfony\Component\Translation\Loader\TranslationLoader::class), E_USER_DEPRECATED);
Copy link
Member

Choose a reason for hiding this comment

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

the call to trigger_error should be just after the namespace (see e.g. https://github.com/symfony/symfony/blob/3.4/src/Symfony/Bundle/TwigBundle/Command/DebugCommand.php#L14)

Copy link
Member Author

Choose a reason for hiding this comment

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

I did not know. Thank you.

@xabbuh
Copy link
Member

xabbuh commented Jul 26, 2017

The changelog files for the FrameworkBundle and the Translation component should be updated for 3.4.

@Nyholm Nyholm force-pushed the translation-move-loader branch from 6954c9c to 8210985 Compare July 28, 2017 17:14
@Nyholm
Copy link
Member Author

Nyholm commented Jul 28, 2017

Thank you for the feedback. I've added change logs.

Copy link
Member

@chalasr chalasr left a comment

Choose a reason for hiding this comment

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

This is now at the same level of LoaderInterface and e.g. XliffLoader which is about loading messages. Should we think of a better name?

// load any existing translation files
$finder = new Finder();
$extension = $catalogue->getLocale().'.'.$format;
$files = $finder->files()->name('*.'.$extension)->in($directory);
Copy link
Member

Choose a reason for hiding this comment

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

I would drop the finder requirement for an iterator.

Copy link
Member

Choose a reason for hiding this comment

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

Already pointed by @javiereguiluz but @Nyholm said it would need the Finder dep anyway for some other changes he wants to make. So, probably good as is.

@chalasr
Copy link
Member

chalasr commented Aug 1, 2017

Should probably be renamed to TranslationReader (#23667).

@Nyholm
Copy link
Member Author

Nyholm commented Aug 2, 2017

I've moved the changes in this PR to #23667. The PR's were too tightly coupled.

@Nyholm Nyholm closed this Aug 2, 2017
fabpot added a commit that referenced this pull request Aug 29, 2017
… move TranslationLoader to TranslationComponent (Nyholm)

This PR was merged into the 3.4 branch.

Discussion
----------

[Translation] Create an TranslationReaderInterface and move TranslationLoader to TranslationComponent

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

Create an interface for TranslationLoader. I put this in the Translation component even though the TranslationLoader implementation is in the FrameworkBundle. (Here is a PR moving the TranslationLoader to the Translation component: #23666)

We need this in PHP-translation. We currently have to rewrite things in strange mannar like: https://github.com/php-translation/symfony-storage/blob/0.2.2/src/FileStorage.php#L62-L64

Commits
-------

5bc50da Create an interface for TranslationReader and moved TranslationLoader to Translation component
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.

7 participants