Skip to content
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

str_slug() and the Hungarian language #16622

Closed
blackfyre opened this issue Dec 1, 2016 · 9 comments

Comments

Projects
None yet
3 participants
@blackfyre
Copy link

commented Dec 1, 2016

  • Laravel Version: 5.2.41 upwards

Description:

The problem with the Hungarian diacritics that they get transformed wrongly during the slug generation.
Ö,Ő gets transformed to OE and ÜŰ gets transformed to UE, while these should be o and u respectively.
This was introduced in ee8dde1 with the charsArray() protected function.

@GrahamCampbell

This comment has been minimized.

Copy link
Member

commented Dec 1, 2016

Please submit bug reports to the stringy library. We always used them in the first place, so that change to the chars array would have happened anyway, we just removed the dependency on them, and now directly copy the small part of the codebase we need.

@blackfyre

This comment has been minimized.

Copy link
Author

commented Dec 18, 2016

If some one is looking for a "quick" solution, voku/Stringy's methods can be used as a replacement serveral ways.

First version

$stringy = Stringy\Stringy::create('fö fü fófőfúféfáfű'); 
echo $stringy->toAscii()->dasherize(); // will result in: fo-fu-fofofufefafu

Second version

  1. Create a Helpers.php file where ever you like.
<?php

if (! function_exists('str_slug')) {
    /**
     * Generate a URL friendly "slug" from a given string.
     *
     * @param  string  $title
     * @param  string  $separator
     * @return string
     */
    function str_slug($title, $separator = '-')
    {
        return (string) \Stringy\Stringy::create($title)->slugify($separator,'en');
    }
}
  1. Add it to the bootstrap/autoload.php file.
require __DIR__.'/../app/Helpers/HelperOverload.php';
require __DIR__.'/../vendor/autoload.php';
  1. Use str_slug() as intended 😄
@GrahamCampbell

This comment has been minimized.

Copy link
Member

commented Dec 28, 2016

@blackfyre Please send a PR to danielstjules/Stringy, then everyone can get this fix, including Laravel, rather than just fixing this on your own app.

@blackfyre

This comment has been minimized.

Copy link
Author

commented Dec 28, 2016

@GrahamCampbell This is an on-going problem since the 2nd of January, 2016, please see danielstjules/Stringy#116 for the details.

@GrahamCampbell

This comment has been minimized.

Copy link
Member

commented Dec 28, 2016

We need to encourage them to fix it then, for the benefit of everyone.:)

@GrahamCampbell

This comment has been minimized.

Copy link
Member

commented Dec 28, 2016

It doesn't seem like anyone has actually PRed a fix to stringy, unless I missed it?

@blackfyre

This comment has been minimized.

Copy link
Author

commented Dec 28, 2016

Actually, in Daniel's last comment, he said, that he'll do something in the holidays 😄

@blackfyre

This comment has been minimized.

Copy link
Author

commented Apr 27, 2017

Daniel released a new version of danielstjules/Stringy.

@fernandobandeira

This comment has been minimized.

Copy link
Contributor

commented Apr 28, 2017

@blackfyre I've synced with the new version, check #18974 this shouldn't be a problem anymore on 5.5. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.