Cyrillic product names in URL segments (slug)

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!
D-Cell
Posts: 23
Joined: 17 Dec 2018, 17:47

Cyrillic product names in URL segments (slug)

Post by D-Cell » 17 Feb 2020, 22:46

Hello!

I`m developing a store with Aimeos 2019.10. The main language of this store is Ukrainian, so product names are written in Ukrainian. According to this, i have a cyrillic symbols in my URLs, what is bad for SEO.

Each time i add a product i have to add a custom latin text (on the Texts tab of product page) to use it as URL segment. This is terrible when i have a lot of products.

Please, tell me, is there any way to transform cyrillic name of product to latin symbols and save it as text for URL segment along with product?

My environment is CentOS 7, PHP 7.3, Laravel 6.2, Aimeos 2019.10

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

Re: Cyrillic product names in URL segments (slug)

Post by aimeos » 18 Feb 2020, 11:25

PHP has the "iconv" method to translate between character sets but the results are somtimes terrible:
https://www.php.net/manual/en/function.iconv

The fastest way: Use product labels with latin characters and remove the url segments. You always have to add a label, so it's no extra effort and they are used if no url segments are available.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

D-Cell
Posts: 23
Joined: 17 Dec 2018, 17:47

Re: Cyrillic product names in URL segments (slug)

Post by D-Cell » 18 Feb 2020, 13:00

aimeos wrote: 18 Feb 2020, 11:25 PHP has the "iconv" method to translate between character sets but the results are somtimes terrible:
https://www.php.net/manual/en/function.iconv

The fastest way: Use product labels with latin characters and remove the url segments. You always have to add a label, so it's no extra effort and they are used if no url segments are available.
Hi! Thank you for reply.
But still, if i will use product labels with latin characters i`ll get latin product names among ukrainian descriptions, attributes, characteristics and other texts in my store.

Good point about "iconv", but, as for me, is better to use a custom php function for transliteration.

I was thinking about writing one and use it to transliterate cyrillic product names before posting a product. Then create a new text in Texts tab and use previously transliterated name as URL segment. Unfortunately, i have no idea how can i add this new text field automatically during saving the product instead of creating this text field manually.
Could you advise something? I think i`m not the only one, who faces this issue. It would be a great improvement for aimeos webstores, which use cyrillic languages.

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

Re: Cyrillic product names in URL segments (slug)

Post by aimeos » 18 Feb 2020, 17:56

D-Cell wrote: 18 Feb 2020, 13:00 But still, if i will use product labels with latin characters i`ll get latin product names among ukrainian descriptions, attributes, characteristics and other texts in my store.
Not if each product has a text of type "name" but that wouldn't reduce the work for your editors.
D-Cell wrote: 18 Feb 2020, 13:00 I was thinking about writing one and use it to transliterate cyrillic product names before posting a product. Then create a new text in Texts tab and use previously transliterated name as URL segment. Unfortunately, i have no idea how can i add this new text field automatically during saving the product instead of creating this text field manually.
You could extend the product text subpart and overwrite the fromArray() method. There you can add a new text item automatically with "url" type when the product is saved:
https://github.com/aimeos/ai-admin-jqad ... #L305-L350

Alternatively, you could automatically add a text entry of type "url" with the transliterated name in the product detail view via Javascript/Vue.js for new items when the product.label field has been filled:
- https://github.com/aimeos/ai-admin-jqad ... ct.js#L148
- https://github.com/aimeos/ai-admin-jqad ... #L667-L678
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

D-Cell
Posts: 23
Joined: 17 Dec 2018, 17:47

Re: Cyrillic product names in URL segments (slug)

Post by D-Cell » 20 Feb 2020, 20:49

Thank you! I`ll try to use one of the options you provided and post the solution here in case of success.

D-Cell
Posts: 23
Joined: 17 Dec 2018, 17:47

Re: Cyrillic product names in URL segments (slug)

Post by D-Cell » 24 Feb 2020, 23:27

Ok...i give up (. Seems like i am not qualified enough to achieve it. Hope the automatic product name transliteration will be added to one of the future versions of Aimeos. It would be a great improvement for those people, who uses cyrillic languages in their stores.

Post Reply