magento / community-features

Magento Features Development is an Initiative to Allows Community Memebers Join to Development of Magento Features
46 stars 18 forks source link

Internationalized routing for Base Router #46

Open cmuench opened 6 years ago

cmuench commented 6 years ago

Last week, Symfony published a new component for realizing international routes. http://symfony.com/blog/new-in-symfony-4-1-internationalized-routing

I would like to see this feature in the Magento Base Router. This will offer us locale specific routes.

e.g.

This could be solved by adding new config elements to routes.xml.

My idea is to provide a general replacement for a frontName and explicit mapped rewrites for single actions.

Draft Example:

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
    <router id="standard">
        <route id="catalog" frontName="catalog">
            <module name="Magento_Catalog" />

            <localizedFrontName>
                <prefix frontName="katalog" locale="de_DE" />
            </localizedPrefixes>
        </route>

        <localizedActionPreferences>
            <preference for="catalog/product/view" rewrite="katalog/produkt/anzeigen" locale="de_DE" />
            <preference for="catalog/category/view" rewrite="katalog/produkt/anzeigen" locale="de_DE" />
        </localizedActionPreferences>
    </router>
</config>
korostii commented 6 years ago

Please note that you would probably have to accompany any similar changes with accompanying SEO changes, namely adjust sitemap.xml generation and\or implement <link rel="alternate" hreflang="..." ... /> tags rendering on corresponding pages themselves. This is necessary in order to inform the search engines that these URLs should be considered as localized versions of the same page rather than completely separate pages.

Further reading: https://moz.com/learn/seo/hreflang-tag https://support.google.com/webmasters/answer/189077?hl=en https://support.google.com/webmasters/answer/2620865?hl=en