Multi Language Store

An ecommerce store would serve a broad range of customers across multiple countries, thus it would become necessary to add multiple language options for the customers. By default, english language would be added in the system during installation. All the languages in the system can be viewed on the WhatACart Language page through System >> Localization >> Languages.

How to add Language

To add the new language go to System >> Localization >> Languages, Click on Create, add a new language and Save. Once a new language is added, it would be displayed in the top navigation as a dropdown and would be displayed in the top navigation as well in the admin panel as shown in the image below.

Multi Language Dropdown in Admin

On addition of new language, a multi language dropdown is displayed in admin. On selection of language, the changed language would be applicable on index, update and view screen if translatable. For example Content >> Pages are translatable thus multi language is applicable here but in case of System >> Users is not translatable thus multi language not applicable.

Adding Translations

On addition of new languages, translations for them have to be added. Please refer to http://www.yiiframework.com/doc-2.0/guide-tutorial-i18n.html#using-the-message-command. Here are the steps to generate the translation files.

  • Navigate to project root
  • Open messages/config.php and add the languages which have been added to the system in the languages array. For example ‘languages’ => [‘fr’].
  • Run yii message/extract messages/config.php
  • On successful execution, a folder named fr would be created under messages with all the language translation files. Each file would have a map with key as message in English and value as the translated value which has to be populated.

Multi Language Dropdown in Site

On addition of new language, a multi language dropdown is displayed in front end. On changing language, the site content would be displayed in the changed language if translations are available. If not it would be displayed in english only.

Leave a Reply

Your email address will not be published. Required fields are marked *