wagtail / wagtailtrans

A Wagtail add-on for supporting multilingual sites
http://wagtailtrans.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
104 stars 60 forks source link

Remove locale automatically from slug #187

Closed jkevingutierrez closed 4 years ago

jkevingutierrez commented 4 years ago

Found a bug, please fill out the sections below

Issue summary

When you create a translated page, it always add the locale code to the slug. Is there a way to remove the locale code by default?

I'll explain my use case. I have something like this:

/   (TranslatableSiteRootPage)
    en/        (TransHomePage)
        english-page-1/    (TransLandingPage)

    es/        (TransHomePage)
        spanish-page-1/     (TransLandingPage)

Having WAGTAILTRANS_SYNC_TREE = true when I create an English page, it automatically creates the Spanish version.

The problem is that the Slug of the generated Spanish pages contains -es at the end. I would end up having pages like mysite.com/es/page-es/subpage-es. I know that I can edit manually the Slug of the page to remove the language code. But it would be great to have an easy way to remove the language code in the slug by default, specially if you need to create a lot of new pages of different types.

Maybe using a settings variable and do some validations here:

https://github.com/wagtail/wagtailtrans/blob/4c43f9ddeae79b30a80a08a724e9c5d33aac8d88/src/wagtailtrans/models.py#L278

How to reproduce?

Following https://www.accordbox.com/blog/how-support-multi-language-wagtail-cms/

Technical details

Python 3.8 Django==3.0.9 wagtail==2.10 wagtailtrans==2.1

jkevingutierrez commented 4 years ago

Duplicated of #178