Skip to content

Create an interface for TranslationWriter #23665

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 12 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? ~~~no~~~ yes
Tests pass? yes
Fixed tickets
License MIT
Doc PR

We should provide an interface for the TranslationWriter. This allows other libraries (php-translation) that depend on the Translation component provide different implementations.

/**
* Writes translation from the catalogue according to the selected format.
*
* @param MessageCatalogue $catalogue The message catalogue to dump
Copy link
Member

Choose a reason for hiding this comment

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

These PHPdoc comments use the "dump" verb, but the interface and method names use "write". Should they be consistent?

*
* @throws InvalidArgumentException
*/
public function writeTranslations(MessageCatalogue $catalogue, $format, $options = array());
Copy link
Member

Choose a reason for hiding this comment

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

I guess we can't change this now, but according to Symfony naming conventions, "When an object has a "main" many relation with related "things" (objects, parameters, ...), the method names are normalized". So, this method should probably be called write() instead of writeTranslations().

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure we can. It is a new interface =)

@Nyholm
Copy link
Member Author

Nyholm commented Jul 26, 2017

I made the new interface follow the Symfony naming conventions.

This means that I deprecated TranslationWriter::writeTranslations in favor of TranslationWriter::write

@@ -18,7 +18,7 @@

class TranslationWriterTest extends TestCase
{
public function testWriteTranslations()
Copy link
Member

Choose a reason for hiding this comment

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

The legacy test should be kept with @group legacy and @expectedDeprecation [msg] phpdoc annotations.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you

@chalasr
Copy link
Member

chalasr commented Jul 31, 2017

@Nyholm We still need to add a test for the new write() method, it will be kept when removing the legacy one.

@Nyholm
Copy link
Member Author

Nyholm commented Jul 31, 2017

Thank you @chalasr. I've added a test now.

UPGRADE-3.4.md Outdated
Translation
-----------

* Deprecated `Symfony\Component\Translation\Writer\TranslationWriter::writeTranslations`
Copy link
Member

Choose a reason for hiding this comment

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

... has been deprecated and will be removed in 4.0, use ... instead

UPGRADE-4.0.md Outdated
@@ -506,6 +506,8 @@ Translation
-----------

* Removed the backup feature from the file dumper classes.

* Deprecated `Symfony\Component\Translation\Writer\TranslationWriter::writeTranslations` function, use `Symfony\Component\Translation\Writer\TranslationWriter::write` instead.
Copy link
Member

Choose a reason for hiding this comment

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

Removed ..., use ... instead.

*/
public function writeTranslations(MessageCatalogue $catalogue, $format, $options = array())
{
@trigger_error('Method writeTranslations() is deprecated. Use write() instead.', 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.

@trigger_error(sprintf('Method %s() is deprecated since version 3.4 and will be removed in 4.0. Use write() instead.', __METHOD__), E_USER_DEPRECATED);

@@ -88,4 +88,19 @@ public function writeTranslations(MessageCatalogue $catalogue, $format, $options
// save
$dumper->dump($catalogue, $options);
}

/**
* @param MessageCatalogue $catalogue The message catalogue to write
Copy link
Member

Choose a reason for hiding this comment

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

the method description should be kept

@Nyholm
Copy link
Member Author

Nyholm commented Aug 5, 2017

Thank you for the review

@@ -18,6 +18,10 @@

class TranslationWriterTest extends TestCase
{
/**
* @group legacy
* @expectedDeprecation Method writeTranslations() is deprecated. Use write() instead.
Copy link
Member

Choose a reason for hiding this comment

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

needs to be updated

@Nyholm Nyholm force-pushed the translation-writer branch from d056c0e to faf7c2b Compare August 6, 2017 19:10
@chalasr
Copy link
Member

chalasr commented Aug 12, 2017

Fabbot complains :)

@Nyholm
Copy link
Member Author

Nyholm commented Aug 12, 2017

Thank you. I've update the PR

@Nyholm
Copy link
Member Author

Nyholm commented Aug 19, 2017

Is it anything I can do to get this PR merged?

@nicolas-grekas
Copy link
Member

Thank you @Nyholm.

nicolas-grekas added a commit that referenced this pull request Aug 22, 2017
This PR was squashed before being merged into the 3.4 branch (closes #23665).

Discussion
----------

Create an interface for TranslationWriter

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

We should provide an interface for the TranslationWriter. This allows other libraries (php-translation) that depend on the Translation component provide different implementations.

Commits
-------

c25eafa Create an interface for TranslationWriter
@Nyholm
Copy link
Member Author

Nyholm commented Aug 22, 2017

Thank you for merging.

This was referenced Oct 18, 2017
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.

6 participants