flarum / framework

Simple forum software for building great communities.
http://flarum.org/
6.27k stars 826 forks source link

Slug transliteration #194

Closed tobyzerner closed 3 years ago

tobyzerner commented 9 years ago

Ex: https://chanphom.com/forums/luat-choi-chan-pro.29/ from "Luật chơi Chắn Pro"

yagobski commented 7 years ago

I just make an improvement for this issue. I use something like wordpress Slug. Can handle utf8 and more ;)

luceos commented 7 years ago

@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.

johannsa commented 7 years ago

Putting implementation aside, any decision on whether allow UTF characters on slugs (à la Wikipedia) or not has been taken?

tobyzerner commented 7 years ago

@johannsa I think the consensus was to make it an option?

Zeokat commented 7 years ago

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.

yagobski commented 7 years ago

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 .

Zeokat commented 7 years ago

@yagobski your commit is mostly incomplete:

yagobski commented 7 years ago

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:

— 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 .

jordanjay29 commented 7 years ago

@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.

Zeokat commented 7 years ago

What will be the right choice when the generated slug is empty because it uses non-friendly characters:

Will be nice know which will be the right option, because both needs different code solutions.

franzliedke commented 7 years ago

@Zeokat I would prefer Option 2.

Zeokat commented 7 years ago

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.

franzliedke commented 7 years ago

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.

Zeokat commented 7 years ago

@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

buiductuan182 commented 7 years ago

Maybe you can use library like this one? https://www.quangminhhanoi.com/dieu-hoa-daikin

renato commented 5 years ago

Is this still planned to land on core or should we use extensions (there are 2 iirc) to solve this?

franzliedke commented 5 years ago

Still planned, the ticket is still open. :wink:

renato commented 5 years ago

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)?

franzliedke commented 5 years ago

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.

franzliedke commented 5 years ago

Another option: https://github.com/sunrise-php/slugger

ivangretsky commented 5 years ago

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!

luceos commented 4 years ago

Symfony 4.4 offers translated slugs:

https://twitter.com/titouangalopin/status/1179436751477231617

https://github.com/symfony/symfony/pull/33768

image
Zeokat commented 4 years ago

But it requires extension intl if i'm not wrong :expressionless:

clarkwinkelmann commented 4 years ago

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.

franzliedke commented 4 years ago

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.

Zeokat commented 4 years ago

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.

askvortsov1 commented 3 years ago

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.