-
Notifications
You must be signed in to change notification settings - Fork 2.5k
[2.1] [WIP] Zend\I18n\Filter\SlugUrl - Made a filter to convert text to slugs #2190
Conversation
Usefull +1 👍 But, I disagree with some parts of your implementation. IMHO a slug is more than the filter of Dasprid or Matthew. EDIT: can you add a unit test to have all parts of a real slug? Input value is "C'est l'histoire de la contrefaçon !", and the excepted value must be "cest-lhistoire-de-la-contrefacon". |
setlocale(LC_ALL, "en_US.{$enc}"); | ||
|
||
//suppress errors @iconv | ||
$filtered = @iconv($enc, 'ASCII//TRANSLIT', $value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't use the @ operateur.
yes, in Portuguese for example we have characters that do not have in English. ex. Profissão (profession) This filter will convert these special characters to an ASCII character nearest "á" to "a" or "é" to "e" $str = "Alimentação"; referring to the code, now intend to improve it because it was a plugin for Zend 1.x did not do much better on it (yet), I would like to know if there is a community interest in having this filter, because I always I needed something. What do you think, we disregard this "pull request", I make the changes and resend? |
That's why I was talking about languages with non-Latin alphabet.
Do you know that your can update a PR? |
About
I totally agree! |
*/ | ||
public function filter($value) | ||
{ | ||
if (!function_exists('iconv')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that you must move this test in the constructor, because the class is useless without this extension. Why do you test the function insteadof the extension is loaded?
I agree with b-durant. This implementation looks quite complicated. I had a similar implementation as Dasprid and so far it worked really well. |
public function testRemoveGreekCharacters() | ||
{ | ||
$filter = new SlugUrlFilter(); | ||
$this->assertEquals('aaaabbbb', $filter->filter('φψξAAAAωϑBBBB')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if it's the right usage: slug is available only for a latin website at this time. How does the developer of a Greek blog?
You can use PR 2105 maybe (like DASPRiD).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I saw that there is already "DASPRiD" that does the same thing and more! ... I did not know there was already something in ZF2, thank you friends.
We can close this PR?
@agutoli I'm going to port my slugifier and unidecoder to ZF. I earlier planned to get it done for 2.0, but ran out of time, so it'll be in in 2.1. As you said that you're fine with closing the PR, I'll do so now. |
@DASPRiD I fully agree with the closure, after their class is much more comprehensive and better defined, have no doubt. Anyway, glad to have learned more about the Zend. Thank you all! |
This filter does the job of converting text with special characters to a slug that can be used in a url.