Automated arabic slug I am using TextWithSlug for generating slug from the title and its working fine when using English letters in the title.
But when i enter the title in Arabic letters the slug is generating in English which is fine but I want that slug to be generated in Arabic letters too.
https://prnt.sc/puj69b
code:- TextWithSlug::make('Title')
->sortable()
->rules('required', 'max:255')
->slug('body'),
Slug::make('Slug'),
yes i am using the following package:- https://github.com/benjaminhirsch/nova-slug-field
After adding pass options ->slugifyOptions(['lang' => 'ar']) it is showing the below error
Method Benjaminhirsch\NovaSlugField\TextWithSlug::slugifyOptions does not exist.
Thanks for your quick reply.
Sorry wrong one. Should be Slug::
Slug::make('Slug')->slugifyOptions(['lang' => 'ar']),
Actually it seems that the lang you can pass is used for parsing the input. There does not seem to be any way of getting it to output it as arabic
https://github.com/pid/speakingurl
I'm afraid you would have to create your own version of the extension (or suggest the author change his implementation)
@sinnbeck can you suggest me any other package or way around through which I can achieve this?
I already spend a lot of time and this is my first laravel project and don't know how to create an extension.
I really appreciate your help.
Any reason you want Arabic characters in the url? I think most browsers will have a hard time with this
A assume that works for your browser but not mine then :)
https://imgur.com/DIprM7Z
Anyway. I think I have found a solution for you. Its not pretty but it works.
https://imgur.com/2ecS9WT
You can pass an array of mapping characters to other characters
Here is a simple example with 1 character (ignore that laracasts flips the =>)
->slugifyOptions(['custom' => ['ي' => 'ي'])
Cool. That part should be easy enough
str_replace(' ', '-', $string);
Please sign in or create an account to participate in this conversation.