Question

I have multi language store, what I want to accomplish is to have my search bar categories field translated into two languages. I cannot seem to find how to translate "All Categories" to another language. I saw that it is hard coded in a file called form.mini.phtml. This is just a small part of the file but so you can have the idea.

<?php if($currentCategory != ""): ?>
    <?php echo $currentCategory ?>
<?php else: ?>
    <?php echo __('All Categories'); ?>
<?php endif ?>

Is there any way I can have this part translate so whenever a user opens the German version of the website it will say "Alle Kategorien" and when the English version is opened "All Categories" Thanks.

Was it helpful?

Solution

First, you have to check if you have installed the language pack for each of your language? If you have installed it, the translation should be done automatically by the Magento. If that string is still not translated yet after installing the language pack, you need to check if the string (in this case, All Categories) is available in the translation dictionary (i.e in i18n/de_DE.csv if you installed the German language pack). If you can't find it, you need to add it manually. Example are given below for German language pack.

  1. install this German language pack (or update if you have already installed it). I prefer using the Method #1. Install via Composer for this example.

  2. after installing the module, check if the string you want to translate to German is available in vendor/mageplaza/magento-2-german-language-pack/de_DE.csv. If you find that the translation for All Categories is not available, you need to add it manually (proceed to step 3).

$ grep '"All Categories"' vendor/mageplaza/magento-2-german-language-pack/de_DE.csv 
  1. add the translation manually (see here) if your string translation is not available.

You need to repeat these steps for other language(s) translation.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top