How to stop conversion from cyrillic to latin in product URL segments?

Help for integrating the Laravel package
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
kdim95
Advanced
Posts: 206
Joined: 26 Aug 2022, 12:17

How to stop conversion from cyrillic to latin in product URL segments?

Post by kdim95 » 04 Nov 2022, 09:35

Laravel framework version: 9.38.0
Aimeos Laravel version: * 2022.07.2
PHP Version: 8.1.12
Environment: Linux

Aimeos automatically translates cyrillic to latin when saving the product URL segment, how do I prevent this from happening?

User avatar
aimeos
Administrator
Posts: 7896
Joined: 01 Jan 1970, 00:00

Re: How to stop conversion from cyrillic to latin in product URL segments?

Post by aimeos » 06 Nov 2022, 19:26

Because only latin characters are allowed in URLs, translation is always done automatically.

You can change that by adding a custom macro for the slug() method in the Aimeos string class:
https://github.com/aimeos/aimeos-base/b ... #L156-L165

Code: Select all

\Aimeos\Base\Str::macro( 'slug', function( $str, string $lang = 'en', string $sep = '-' ) : string {
	return $str;
} );
Add that code toy our AppServiceProvider class.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

kdim95
Advanced
Posts: 206
Joined: 26 Aug 2022, 12:17

Re: How to stop conversion from cyrillic to latin in product URL segments?

Post by kdim95 » 07 Nov 2022, 09:33

Thanks, that works.

I added the code inside public function boot()

This is needed because I need to keep the original cyrillic URLs of an existing shop.

Post Reply