cms icon indicating copy to clipboard operation
cms copied to clipboard

Unable to generate slug with Chinese characters

Open billmn opened this issue 5 years ago • 7 comments

Bug Description

If you try to add Chinese characters in the Title field of an entry, Statamic doesn't generate the slug.

How to Reproduce

  1. In the Title field of an entry, insert: 你好,世界
  2. Press "Save"

Statamic version: 3.0.25

PHP version: 7.4.8

Install method (choose one):

  • Fresh install from statamic/statamic

billmn avatar Nov 07 '20 17:11 billmn

I think this issue is related to pid/speakingurl#61, an issue on speakingurl which is the package used by Statamic to create the slugs.

The update the maintainer suggests on there is for speakingurl to be swapped out in favour of Limax, another package.

duncanmcclean avatar Nov 26 '20 22:11 duncanmcclean

Doesn't look like we can use Limax as it's intended to be used server side (Node) and has a huge package load size if attempting to run client-side. I couldn't get it to compile.

If we want to support Chinese and other multibyte characters, we'll need to find a compact library that can handle it.

jackmcdade avatar Jul 06 '21 02:07 jackmcdade

Any news on this. Also affects taxonomy terms.

sheldonkotyk avatar Jan 10 '23 00:01 sheldonkotyk

What if we replaced https://github.com/pid/speakingurl with a javascript helper that hits a server-side endpoint so we can use the same logic on both client/server and not worry about js package loads. 🤔

@jasonvarga whatcha think?

jackmcdade avatar Sep 17 '23 23:09 jackmcdade

Different issue, but slug related... https://github.com/statamic/cms/pull/8429 cc/ @martyf

Maybe we can tackle both at once, if we're taking a pass on slug generation?

jesseleite avatar Jan 30 '24 22:01 jesseleite

What if we replaced pid/speakingurl with a javascript helper that hits a server-side endpoint so we can use the same logic on both client/server and not worry about js package loads.

That's what I was thinking too. At least for the more important language based ones like entry slugs. For stuff like field handles maybe it's less important.

jasonvarga avatar Jan 31 '24 01:01 jasonvarga

Different issue, but slug related... #8429 cc/ @martyf

Maybe we can tackle both at once, if we're taking a pass on slug generation?

It doesn't look like I linked it to the PR but that edge case has since been fixed in the current slug implementation (see #8923). It'll also be fixed when we merge #9440 since Laravel's Str::slug helper covers it too 💪

duncanmcclean avatar Feb 01 '24 12:02 duncanmcclean

This has been fixed in Statamic 5, which we're hoping to release in the next few days/weeks.

duncanmcclean avatar Apr 05 '24 14:04 duncanmcclean