DEV Community

Cover image for Adding and maintaining new languages in Shopware is now dead simple
Marco Steinhaeuser for shopware

Posted on • Originally published at shopware.com

Adding and maintaining new languages in Shopware is now dead simple

With Shopware v6.7.3.0, we introduced a very interesting feature for those of you who have to deal with languages and translations in your online shops. As we ported the functionality of the formerly known Shopware language pack into the core of Shopware, installing and maintaining languages in Shopware became dead-simple. In this blog post, you will learn how it works and what the limits of this modus operandi are.

Translation platform on Crowdin

The basis is our translation platform with the generous help of Crowdin. All newly appeared language keys (AKA "snippets") in the Shopware core will automatically be available in Crowdin, followed by an automatic translation utilising Amazon Translate. Crowdin shows how much of a language is human-translated via the colour of the status bar in the language overview: Blue means machine translated, green means human translated.

screenshot of progress bars in Crowdin

All translations will be synchronised daily to the repository github.com/shopware/translations/, after synchronisation they can be used as shown in the following steps.

Adding a new translation to Shopware

Shopware comes with just three pre-installed languages: English โ€“ British and American โ€“ plus German. Let's say you want to extend your online shop with Spanish like it is spoken in Spain (es-ES).

Login to your server via the terminal, navigate to the location of your .env file, and execute the following command:

$ php bin/console translation:install --locales=es-ES
Enter fullscreen mode Exit fullscreen mode

Just like that, Spanish is installed and already activated in your Shopware instance. All you have to do now is login to your administration panel and adjust the URL for your new language, for example https://example.com/es/ (replace example.com with your domain). When you navigate to this URL, you'll now see Spanish translations all over โ€“ well, except for your products and custom text. ๐Ÿ˜‰

part of Shopware storefront saying that there are no products in spanish

Maintaining translations

Let's go a step further and update your new translation:

$ php bin/console translation:update --locales=es-ES
Enter fullscreen mode Exit fullscreen mode

This way, you will fetch the latest language keys, no matter if used or not, and also the latest human approved translations by the community.

There are even more commands and options available. Read more about it in the documentation.

If you want to have your very own behaviour for special language keys in your online shop, there is no need to fight about the correct phrase on our translation platform. Think of cart vs. basket vs. trolley, for example. In this case, simply make use of Shopware admin ยป General ยป Languages ยป Manage Snippets. These changes will be stored in the database and have first loading priority. This way, your newly installed Spanish translation set stays update-safe, and you can have your very own style without bothering others. However, other community members still can make use of it.

The coolest advantage of these CLI commands is that you could even use the update method described above in a cron job or even in your continuous integration setup โ€“ at least for staging: stay up-to-date with the latest community corrections in this translation.

A bit off-topic and out of scope for this blog post, but I don't want to miss pointing you to this great translation QA-tool for your CI: https://github.com/boxblinkracer/phpunuhi โ€“ indispensable for bigger online shops with any quality approach, isn't it? Especially, as it was developed by one of my best mates in the community, @boxblinkracer

Limits and disclaimer

Please note that this blog post is about translations of the core language keys / snippets for the storefront as well as the administration panel of your Shopware instance. No product information nor any other database entries have automatically been translated.

With the method described above, you are installing translations made by the community. Shopware can not give any guarantee on the quality nor the content of these translations. We cannot proofread languages we do not speak, which means there is the possibility of a bad actor adding wrong or even offensive text into translations. If you gain knowledge of it, please inform us as soon as possible to help keeping the quality of the translations high. Also, please avoid the automatic update method in production and only use it on staging for this reason.

What I have described here will only work for translations available on translate.shopware.com. There are two other methods if you need a language not available through the Crowdin setup:

  1. (Preferred) Get in touch and request another language to be added to our Crowdin instance. We can quickly provide at least an automated translation, which will โ€“ over time, and depending on the quality of the automation โ€“ be approved by a human being.
  2. Create your own plugin on the basis of the Shopware language plugin. This way, you have full ownership, without any community connection.

Last but not least: We will deliver any language available on translate.shopware.com, be it LTR (left to right) or RTL (right to left, like Arabic, for example), the way described above knowing that there might be some display glitches. This is because we rely on you, the community. You as native speakers have more experience in properly solving this topic in no time as we might still struggle in planning, sorting it out, resolving and testing it. Looking forward to a proper solution, best as a free/libre and open source plugin for Shopware. Don't hesitate to ping us once you're done with it!

Next steps

Send your translators to translate.shopware.com for approving existing auto-translations, correcting them and let the remaining language keys be translated for the benefit of the whole community.

We are planning to publish a so called "in-context translation": There will be a demo Shopware instance that translators can use to see the context of what they are translating โ€“ everything connected to Crowdin. Once this is finished, we will announce it in this channel as well as social media.

Looking for help or experienced translators? We created a club in hub.shopware.com, especially for translators. We will be there to answer your translator questions.

Have fun with this new feature and let us know how it is working for you!

Top comments (0)