With laravel(I am using v.9.x) Str:slug you can convert a string to a slug like:
Woman life freedom
to
Woman-life-freedom
but the problem is when you pass a non-english string to this method, laravel translates it to English like in persian:
زن زندگی آزادی
it converts to:
zn-zndgy-azady
How to prevent laravel to do this?
The simple solution to this problem is to pass
nullor0as the third argument to the methodsluglike this:Why?
if you look at the source code of the slug method in the
Strclass at/vendor/laravel/framework/src/Illuminate/Support/Str.php, you can see this:It is clear that the third parameter
$languageallows you to translate the language if it is specified, else it will use English as the default.So by passing the value
0(ornull, that is better), the condition is not executed and the text remains in its original form.