Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Unique Slugs Multilanguage #1086
Hi, really great work here!
I've been trying and failing to achieve multilanguage unique slugs.
Cockpit core handles smoothly multilanguage slugs creation:
Unique Slugs addon works great but only if "slug" field is not localized:
Is there a way to achieve this?
@decodedesign I added the support for localized fields.
Can you test it, please? Than I'll pull it to the master branch. It worked on my local machine with the following setup:
languages: de: Deutsch unique_slugs: collections: # testlocale: title testlocale: - title # type: text, localize: true - fallback # type: text, localize: true - tags|0 # type: tags, localize: true localize: # testlocale: title testlocale: - title # don't add the language postfix - "title" and not "title_de" - fallback - tags|0
If you omit the localize key, it should work like before.
Just one comment, I can see (and also disabling localization configs), that if:
I tried also with master-branch addon, and it works the same as described above.
Thank you for the great job!
Thanks @decodedesign for finding this issue. I never realized that behaviour. It actually never worked before with multiple duplicated values... I was so focused on keeping it small and simple, that I forgot the obvious thing.
I didn't do any performance tests, yet. My normal use case is to create some pages via ui. For unique checks with massive api calls to create items, you might use the
I think this use case (localized content, via admin UI, which generates similar slugs) could be pretty common. I'm thinking in some blog posts or news articles, even promotional landing pages, created months later, that could have the same slugs.
Thank you again!
thanks for testing it. I added one last change to enable checks on user updates. Enable it with
If it works for you, this issue can be closed.