Blog navigation keyboard_arrow_down

Blog Rss rss_feed

The New PrestaShop Translation System: What Has Changed and What Are the Benefits

The New PrestaShop Translation System: What Has Changed and What Are the Benefits

Translations play a key role in the success of any e-commerce platform, especially in global markets. PrestaShop has always offered built-in localization tools, but starting from version 1.7.6.x, there was a significant shift to a new translation system. Let's explore how the new system differs from the old one, the advantages it offers, and why this change was necessary.

The Old Translation System (Pre-1.7.6.x)

Before version 1.7.6.x, translations in PrestaShop were stored in PHP files as string arrays. This process was automated through the admin panel, where users could modify or add translations without manually editing the code. Here's an example of a translation string in the old system:

global $_MODULE; $_MODULE = array(); $_MODULE['<{favoriteeasy}prestashop>favoriteeasy_d8f16dbe6407f93fffdf30e1aa76aaa1'] = 'Wishlist / Favorite products'; $_MODULE['<{favoriteeasy}prestashop>favoriteeasy_a57f60d12bb941abf2b34a8f7cc1374e'] = 'All data will be deleted, are you sure?';

While the system allowed users to easily manage translations via the admin panel, it had several limitations:

  • Fragmented translation files: Each module and theme had separate translation files, making it difficult to manage when scaling up or handling large numbers of translations.
  • Risk of overwriting during updates: Translations could be overwritten during module or theme updates, leading to a loss of custom modifications.
  • Performance issues: As the number of languages and translations grew, the system slowed down, as PHP files were processed every time a translation was needed.

The New Translation System (Since Version 1.7.6.x)

With version 1.7.6.x, PrestaShop adopted a new translation system, powered by Symfony and its Symfony Translation component. Now, translations are stored in the XLIFF (XLF) format, a widely-used standard for managing translations.

Here’s an example of a translation string in the new format:

<trans-unit id="favoriteeasy.list_wishlist" resname="list_wishlist"> <source>Wishlist / Favorite products</source> <target>Wishlist / Favorite products</target> </trans-unit>

Key advantages of the new system include:

  • Centralized management: All translations are now organized in one place, simplifying management through the admin panel.
  • Resilience to updates: Custom translations are no longer overwritten during module or theme updates, ensuring your changes are preserved.
  • Improved performance: XLIFF files are processed faster, reducing server load and speeding up your store.
  • Compatibility with professional tools: XLIFF is a standard format for translation management systems, such as Poedit and Crowdin, making it easier to work with large-scale translations and localization efforts.

Why Was the Change Necessary?

The old system worked for basic needs, but it lacked the flexibility and performance needed for large stores with multiple languages. As PrestaShop's development team explained:

"We updated the translation system to make localization more flexible and user-friendly. The new structure improves performance and eliminates issues related to losing modifications during updates."

Examples of Using the New System

For example, if a store owner wants to change the text on the "Add to cart" button, the old system required finding and editing the PHP file through the admin panel. This change could be lost during an update.

In the new system, translations are safely stored in XLIFF, ensuring that custom modifications persist even after updates. Here’s how it looks in the new format:

<trans-unit id="cart.add_to_cart" resname="add_to_cart"> <source>Add to cart</source> <target>Buy now</target> </trans-unit>

What Does This Mean for the Future?

With the new XLIFF-based system, PrestaShop is more compatible with professional localization tools, offering greater flexibility for automating translations and managing multilingual stores. It also enables faster and more efficient language additions and integrations with global markets.

The new PrestaShop translation system is a significant improvement that makes localization easier, more reliable, and faster. If you haven’t yet switched to the new system, update PrestaShop and experience its benefits.

Share your experience with the new translation system in the comments — how has it changed the way you handle localization in your store?

Was this blog post helpful to you?

    
No comments at this moment
close

Checkout

close

Favourites