Closed tobyzerner closed 3 years ago
I just make an improvement for this issue. I use something like wordpress Slug. Can handle utf8 and more ;)
@franzliedke personally I use the intl extension a lot. It allows for easy implementation of monetary values as well. And it's easy to install as well.
Putting implementation aside, any decision on whether allow UTF characters on slugs (à la Wikipedia) or not has been taken?
@johannsa I think the consensus was to make it an option?
I'm one of those who thinks that will be better use the same approach as WordPress because from my experience (more than 6 years using WordPress) is near to perfect.
The problem using intl
extension can be shared hostings, maybe some don't have that extension enabled by default.
I already suggest wordpress approach in commit but was refused by the dev team
2017-05-05 23:29 GMT+02:00 Zeokat notifications@github.com:
I'm one of those who thinks that will be better use the same approach as WordPress because from my experience (more than 6 years using WordPress) is near to perfect.
The problem using intl extension can be shared hostings, maybe some don't have that extension enabled by default.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/flarum/core/issues/194#issuecomment-299580332, or mute the thread https://github.com/notifications/unsubscribe-auth/AANfNKN8odduSfjEWB3L10AsmJgtJyGUks5r25SpgaJpZM4Fg_4Q .
@yagobski your commit is mostly incomplete:
seems_utf8()
, get_locale()
, etc. It was just a suggestion it can be improved.
2017-05-06 12:26 GMT+02:00 Zeokat notifications@github.com:
@yagobski https://github.com/yagobski your commit is mostly incomplete:
- First you copy-paste WordPress code, also ignoring functions like seems_utf8() , get_locale(), etc.
- WordPress code is under GPL license: flarum/framework#1148 (comment) https://github.com/flarum/core/pull/1148#issuecomment-287695125
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/flarum/core/issues/194#issuecomment-299630467, or mute the thread https://github.com/notifications/unsubscribe-auth/AANfNGu7--8vfB4raVMK2RTZ00yUmYQ-ks5r3ErAgaJpZM4Fg_4Q .
@yagobski I believe the concern is that borrowing code from a GPL project will force Flarum under the GPL, and that's not a desired outcome.
Make sure any code you borrow is licensed freely (public domain) or with something compatible with MIT. GPL and other sharealikes/copyleft (any Creative Commons license with 'SA') are not compatible and will be rejected for inclusion into Flarum.
What will be the right choice when the generated slug is empty because it uses non-friendly characters:
16-7s8eds5e68gd6se7d
16-
(note that -
at the end is added by current code on empty titles).Will be nice know which will be the right option, because both needs different code solutions.
@Zeokat I would prefer Option 2.
Yes @franzliedke that option will be our best choice. The problem is that Flarum always add char -
after the discussion id. I'm trying to locate what files also involve adding that last -
but not much luck.
At the moment only located this line involved into the ending dash:
Handling the javascript part is the problem for me.
Hmm, the URL without slug is already understood: https://discuss.flarum.org/d/187.
That means that only the URL generation code has to be adapted.
@franzliedke Yes, slugs with discussion-id-only are already understood and also gives us some duplicated content because both urls returns "HTTP status 200" without any redirection (301) that search engines can understand. Anyway, that's another history.
I'm speaking about the lines of code that add the dash after discussion-id slug (for example, on empty slugs the autogenerated slug is https://discuss.flarum.org/d/5772-- , which seems a little ugly).
Anyway here we go: https://github.com/flarum/core/pull/1183
Maybe you can use library like this one? https://www.quangminhhanoi.com/dieu-hoa-daikin
Is this still planned to land on core or should we use extensions (there are 2 iirc) to solve this?
Still planned, the ticket is still open. :wink:
I know it's open, but tagged as "needs-discussion". Does it still need discussion, even after flarum/framework#1385 (unfortunately abandoned)? Or we could use the same approach used there (Illuminate\Support\Str::slug
)?
Feel free to send a new PR that takes the changes from flarum/framework#1385 and applies them to the current code. The original author unfortunately did not react anymore.
Another option: https://github.com/sunrise-php/slugger
While this feature is still being discussed, just wanted to mention, that there is a working extension for transliteration for beta 8.1 supported by Friends of Flarum. It is actually a fork of this one. Thanks, people!
Symfony 4.4 offers translated slugs:
https://twitter.com/titouangalopin/status/1179436751477231617
But it requires extension intl if i'm not wrong :expressionless:
Suggestion: put slug generator in the container with an interface for easier extension.
That way extensions like FoF Transliterator can extend it instead of listening for an event and overriding the value.
This way if another part of core uses slugs server side, it will also use the same logic.
Sadly tags is another issue because they use the client side slug()
method in utils/string
.
Okay, for anyone interested, we're finally making some progress here:
If flarum/framework#1975 is merged, we will have a basic transliteration implementation, based on what Laravel brings along. As discussed in detail in this issue, this is great for some, but not helpful for other languages, so more work still needs to be done.
As it doesn't make the current situation (auto-generating slugs) worse for anybody, as far as I can tell, but is an improvement for languages where transliteration makes sense (e.g. German), I think this is a solid improvement that we can make without tackling all the other things that could be done.
That doesn't mean we want to stop here, though. Improving how we cater to international audiences is very important to us (and also very eye-opening).
Based on my understanding of everything that was said in this issue, here is what I would propose as next steps / challenges. Once we agree on these, I would suggest to create separate subtickets that can be scheduled for different releases:
If we manage to make some progress on each of these, I would be very content. :sweat_smile:
Of course, one could go above and beyond with support for language-specific slugging based on the (auto-detected?) language of a discussion, but I would say that's too much for core and clearly extension territory.
I have been waiting this for years and for me @franzliedke plan seems good. I didn't tested Laravel's slugger, but if it do its work good will be at least one step forward :+1:
What i want to add here, is what will happen with tags and usernames slugs, because they maybe also need transliterated or not.
Closing this as solved by flarum/issue-archive#203, extensions can now introduce custom slug drivers to allow any approach imaginable.
If a custom attribute is used to store a new transliterated / modified slug, the Saving
event can be used to set / update that attribute.
Ex: https://chanphom.com/forums/luat-choi-chan-pro.29/ from "Luật chơi Chắn Pro"