Skip to content

Extract the EmojiTransliterator to a dedicated package #49947

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

stof
Copy link
Member

@stof stof commented Apr 5, 2023

Q A
Branch? 6.3
Bug fix? no
New feature? yes
Deprecations? yes
Tickets Fix #49943
License MIT
Doc PR symfony/symfony-docs#18172

Due to the size of the data needed to transliterate emojis, using a dedicated package allows to include the package in the project only when needed.
In Symfony 6.x, the symfony/intl component depends on this component for BC reasons. Root projects can implement a replace hack in their composer.json to skip this package if they don't need it. This dependency will be removed in Symfony 7.0.

"symfony/http-client": "^5.4|^6.0",
"symfony/translation-contracts": "^2.5|^3.0",
"symfony/var-exporter": "^5.4|^6.0"
},
"conflict": {
"symfony/intl": "6.2.*",
Copy link
Member Author

Choose a reason for hiding this comment

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

This conflict is part of the BC layer. An existing project using $slugger->withEmoji(true) will have symfony/string: ^6.2, symfony/intl: ^6.2 as requirement. If we were upgrading to symfony/string 6.3 while keeping symfony/intl 6.2.x, we would not be able to use EmojiTransliterator as symfony/string 6.3 uses the new class from symfony/emoji-transliterator. If symfony/intl is also updated to 6.3, the BC requirement on symfony/emoji-transliterator in symfony/intl will make sure that the code keeps working (for 7.0, you will need to depend on symfony/emoji-transliterator though)

$this->assertNotEmpty($tr->transliterate('😀'));
}

public static function provideLocaleTest(): iterable
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 intentionally kept most tests as legacy tests, to ensure that the BC layer works fine (and I added the assertion about actually instantiating the requested class as my first version of the BC layer was broken in that regard, which could break type checks for existing code using the old class as type). I only removed this test because it relied on the data to find all supported locales, and the data is gone from this component. This is still tested in the new component.

@lyrixx
Copy link
Member

lyrixx commented Apr 5, 2023

Thanks 👍🏼

@stof stof force-pushed the split_emoji_transliterator branch 3 times, most recently from 8f9ab87 to df5ac55 Compare April 5, 2023 16:32
@stof stof force-pushed the split_emoji_transliterator branch from df5ac55 to 88757ed Compare April 5, 2023 17:05
@stof
Copy link
Member Author

stof commented Apr 5, 2023

@fabpot fabbot needs to be updated to exclude the EmojiTransliterator/Resources/data folder, similar to how it excludes Intl/Resources/data

Regarding other CI failures:

  • intl-data is fixed in Fix intl data tests #49948. My PR is not the cause of this failure.
  • Psalm is confused by the conditional class declaration, which is something we are fine about here.
  • the unit test failure on 8.2 is one of those random failures we have these days, with PHPUnit saying OK and PHP crashing after that.

Due to the size of the data needed to transliterate emojis, using a
dedicated package allows to include the package in the project only when
needed.
In Symfony 6.x, the symfony/intl component depends on this component for
BC reasons. Root projects can implement a replace hack in their
composer.json to skip this package if they don't need it. This
dependency will be removed in Symfony 7.0.
@stof stof force-pushed the split_emoji_transliterator branch from 88757ed to 1a44940 Compare April 6, 2023 07:43
@OskarStark OskarStark requested a review from fabpot April 6, 2023 10:54
@OskarStark OskarStark changed the title Extract the EmojiTransliterator to a dedicated package Extract the EmojiTransliterator to a dedicated package Apr 6, 2023
fabpot added a commit that referenced this pull request Apr 8, 2023
This PR was merged into the 6.2 branch.

Discussion
----------

[Intl] Improve the description of the Intl component

| Q             | A
| ------------- | ---
| Branch?       | 6.2
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | n/a
| License       | MIT
| Doc PR        | n/a

As of Symfony 6.0, the symfony/intl component does provide a replacement for ext-intl (that code was moved to symfony/polyfill instead). Now, this component is _only_ about exposing the ICU data (note that I intentionally avoid mentioning the EmojiTransliterator that expands a bit that scope in 6.2 because of #49947)

Commits
-------

7d1e3c5 Improve the description of the Intl component
@@ -24,12 +24,13 @@
},
"require-dev": {
"symfony/error-handler": "^5.4|^6.0",
"symfony/intl": "^6.2",
"symfony/emoji-transliterator": "^6.3",
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe put the emoji-transliterator in composer's suggest section and explain its use

Copy link
Member Author

Choose a reason for hiding this comment

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

We stopped using the suggest section IIRC

Copy link
Member

Choose a reason for hiding this comment

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

Indeed

@nicolas-grekas
Copy link
Member

Closing in favor of #49970, as discussed there. Thanks for the PR!

@stof stof deleted the split_emoji_transliterator branch April 18, 2023 14:34
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.

Split intl packages in smaller packages
8 participants