Closed ShivPandey closed 3 years ago
In theory this would be possible by adding a rules for Emoji or other unicode characters. However, we do not have such a list at the moment, because I think there would be a lot of discussion around what is the correct name. Just looking at your example, you would translate ❤️ into love
, some people would translate it into heart
and the official description is red heart
.
I'm closing this issue, if you're interesting you can create a rule set which you can use just for your project (here is a database with emoji names) and you can create a PR and we will take it under consideration.
@ShivPandey you can use the following code with the https://github.com/ausi/slug-generator library:
$slugGenerator = new SlugGenerator([
'preTransforms' => [
':: [:Symbol:]; :: Any-Name; \'\N{\' > \' \'; \'}\' > \' \';',
],
]);
$slugGenerator->generate('💩'); // pile-of-poo
$slugGenerator->generate('🙃'); // upside-down-face
$slugGenerator->generate('unicode ♥'); // unicode-black-heart-suit
$slugGenerator->generate('unicode ❤'); // unicode-heavy-black-heart
$slugGenerator->generate('unicode ❤️'); // unicode-heavy-black-heart
$slugGenerator->generate('unicode 👍'); // unicode-thumbs-up-sign
This converts symbols to their unicode names, but as you can see in the examples above they might not be the exact names you are looking for.
Input: 'unicode ♥' Output: 'unicode-love'