Back to Top

Translate newly added phrases in overridden files in PrestaShop 1.7

Updated 4 February 2022

In this blog, we will learn how to translate newly created phrases (sentences) in overridden templates, controllers, or classes.

In PrestaShop module development sometimes we need to override core PrestaShop files from a module so there may be a need to add some validation messages on these files.

The issue arises in the translation of these newly added phrases because translations of these phrases do not exist in Prestashop’s default language pack of translations. So when we check these phrases in

International ->Translations section in the respective Translation domain then these phrases do not appear for translations.

Let’s understand with an example,

Searching for an experienced
Prestashop Company ?
Find out More

Suppose, we override a core template file “/themes/classic/templates/catalog/product.tpl” from the module and added a new phrase like this

{block name='page_content_container'}
  <section class="page-content" id="content">
    {block name='page_content'}
      {block name='product_flags'}
        <ul class="product-flags">
          {foreach from=$product.flags item=flag}
            <li class="product-flag {$flag.type}">{$flag.label}</li>

      {block name='product_cover_thumbnails'}
        {include file='catalog/_partials/product-cover-thumbnails.tpl'}
      <div class="scroll-box-arrows">
        <i class="material-icons left"></i>
        <i class="material-icons right"></i>
   <strong> {l s='This is test message' d='Shop.Theme.Catalog'}</strong>

Now, go to the translation section and check this string, you will see that there is no string in translations


Now, go to the app/Resources/translations/default/ShopThemeCatalog.xlf file add the following code

  <file original="themes/classic/templates/catalog/product.tpl" source-language="en-US" target-language="en" datatype="plaintext">
      <trans-unit id="73fe57e637ad5691f4b24ea842b3fb82">
        <source>This is test message</source>
        <target>This is test message</target>
      // don't modify other text, only add newly created text

Now, this string will be visible in translation sections and can be translated into any language.


Similarly, this process will also work for controllers and classes.

That’s all about this blog.

If any issue or doubt please feel free to mention it in the comment section.

I would be happy to help.

Also, you can explore our PrestaShop Development Services & a large range of quality PrestaShop Modules.

For any doubt contact us at [email protected]

. . .

Leave a Comment

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

Be the first to comment.

Back to Top

Message Sent!

If you have more details or questions, you can reply to the received confirmation email.

Back to Home