Magento is made to run in multiple languages. This means that the interface and content needs to be translatable in the configured languages.
In this recipe, you will learn how to make the strings in our module translatable in different languages.
We will create translation files for the module that we created in the previous recipes of this chapter. Ensure that you have the code in your Magento instance.
The following procedure demonstrates how we can manage translations in our module:
To make a test translation, we can create a test translation in the template file that we created in the previous recipe. Add the following code at the end of the file
app/code/Packt/HelloWorld/view/frontend/templates/landingspage.phtml
:<p> <?php echo __('Test translation') ?> </p>
Go to the
/helloworld
page and you will see that the textTest translation
is added on the page.To translate this string, we have to create the
app/code/Packt...