Wagtail finding url name for submitting new translation

We're adding Translations tab to the wagtail admin edit pages. Something like this:-

And if there's no translation yet, add link for creating new translation like this:-

So I was scouring wagtail github repo looking for the url name to be used in the template. The url name for showing the translated version is easy, since it just an edit page. We can find it in wagtail/admin/urls/pages.py through the EditView class.

The url to submit for new translation however can't be found anywhere. Then it comes to my mind maybe it's not implemented in wagtail but in the wagtail-localize app. I looked into that app repo but can't find anything as well. Btw you can find urls for wagtail-localize app in wagtail_localize/wagtail_hooks.py. You can thank me later.

Fortunately I remembered that we can list all urls through django-extensions show_urls command.

poetry run python manage.py show_urls

That will list all urls defined in all installed app. You will see something like this:-

Turn out the urls is define in simple_translation app. The templates then looks like this:-

<fieldset>
    {% if self.heading %}
        <legend class="w-sr-only">{{ self.heading }}</legend>
    {% endif %}
    <div class="{{ self.classname }}">
    {% for translation in self.instance.get_translations %}
    <li><a href="{% url 'wagtailadmin_pages:edit' translation.id %}">{{ translation.title }}</a></li>
    {% empty %}
    <a href="{% url 'simple_translation:submit_page_translation' self.instance.id %}">Add New Translation</a>
    {% endfor %}
    </div>
</fieldset>

On how to add custom tab like above, I guess that would be for another post ;)