Skip to content

Add mechanism to translate URLs #181

@pokoli

Description

@pokoli

As started on #122 we may add a mechanism to add translation to the URL, so an url can be localized.

With the new route decorator introduced on #178, we can use something like:

@route('/product/<uri>')
@route_translation('es_ES', '/producto/<uri>')
def product(self):

This will generate a default route for es_US ('/product/<uri>) and another route for es_ES (`'/producto/').

With this information, we should generate the routes based on website default locale, and website locales. So the following cases will occur.

If website has no locales and website default locale is en_US, the url_for product method must return '/product/<uri>.

If website has no locales and website default locale is es_ES, the url_for product method must return '/producto/<uri>.

If website has multiple locales, the url_for must return the slug in the current transaction locale, prefixed with the variable.

Just started a PoC on https://github.com/pokoli/nereid/tree/route_translations but i think is not as easy as I thought.

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/1930624-add-mechanism-to-translate-urls?utm_campaign=plugin&utm_content=tracker%2F386869&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F386869&utm_medium=issues&utm_source=github).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions