Skip to main content

Who works with Magento knows how difficult it is to translate the system into Portuguese (Brazil), and right here on the blog I explained why it is so difficult to create a 100% complete translation.

Read the post: 100% Translation Lies!

And there is another point in the system where the translation does not arrive, which are the url’s of the system’s native navigation links, such as Checkout, New Account, My Wishlist, etc.

Let’s see in this post how to do this translation to improve not only the aesthetics of your url’s, but also the indexing (SEO) of the site.

Step 1 – The CMS

In the backend system you can create some static content pages, and Magento already creates some of these pages by default, such as Página Inicial (home), Sobre Nós (about-magento-demo-store), Central de Atendimento (customer-service), etc.

So in this situation you can solve the problem by just editing each page by changing the value of the URL field.

Change CMS URL

The portuguese-brazilian translation made available here in the blog already does the translation of some of the CMS content, be sure to get a copy in the post: The Best Translation Magento pt-BR.

Once you make this change, you now need to change the link that calls that page. In this example, go to the menu:

CMS > Static Blocks [Footer Links]

When accessing the block containing the footer links, simply edit the url of the link (About Us).

Changing the link reference

To better understand how the page footer works, read the post: Editing the Footer.

Step 2 – The XML

If you study designing themes and themes for Magento, you already know that many of the links displayed on pages are created from xml. Usually using action blocks “addLink“, “addCartLink“, or “addLinkBlock“.

What these action’s basically do is create the link in html.

But many of them are looking for this url through helpers, as in the client’s example of the Log In link:


This action will fetch within the class:

app > code > core > Mage > Customer > Helper > Data.php

The method getLoginUrl() to get the url of that link.

So the best way to translate this url would be to re-create action addLink like this:

cliente/conta/entrarLog Intrue100

In this example I changed the url helper call to url, and added the prepare=true attribute to re-construct the url. This will transform:

customer/account/login

in

cliente/conta/entrar

With this you can translate the URLs of the links, but now need to point these new url’s to the same pages as the previous links.

Step 3 – URL Rewrite

Here is the functionality already mentioned here on the blog in: Url Amigável no Magento. It can be used in other situations besides the translation of links and url’s.

Access your backend menu:

Catalog > Manage URL Rewrite [Create URL]

For this url translation situation you will choose the “Custom” option, the identifier as well as the description will only be for your control in backend .

The important thing here is the fields “New Path“, “Base Path“, and “Redirect“.

Creating translated URL redirection

New Path – Enter the translated url, eg: cliente/conta/login

Base Path – Enter the original url, eg: customer/account/login

Redirect – Keep “No” so your store keeps displaying the translated url, otherwise it will redirect the new url to the previous url (original).

After saving everything and updating the cache, you can already perform the tests. Remember that you should not change the base/default XML files, always make a copy of them for default/default or your template/theme custom.

Success!

Mario SAM

Welcome to my blog, your go-to resource for everything Magento! Our mission is to provide high-quality, practical, and up-to-date content to help developers, merchants, and e-commerce enthusiasts maximize the potential of Magento 2.