This section allows the user to modify all translations used in PrestaShop.
In order to modify translations, the user must first choose which translation type they want to edit, then the language they want to edit it for (eg. French).
The translation types are as follows:
Once you click on the “Modify” button, you go to the translation interface.
This interface displays two columns. In the left, there’s a tree of translation domains according to the translation type the user chose before.
The tree is composed by separating translation domain parts using dots. Eg:
Admin
├── Actions
├── AdvParameters
│ ├── Feature
│ ├── Help
│ └── Notification
└── Global
The tree above represents the following translation domains:
Only the leaves of this tree are clickable. On the right, the list of wordings belonging to the currently selected domain are shown, each followed by a text field containing its translation to the selected language.
The user can edit translations by filling out the fields, and save them.
On the top of the page, there’s a search box. When the user searches for a wording, the list is filtered, meaning that wordings not matching the search expression are no longer shown on the list and domains containing no matching wording are grayed out.
This section covers where wordings are sourced from and where translations are stored to according to the translation type chosen.
Usually and unless specified otherwise:
Wordings are sourced from the Core’s default catalogue, which is stored as physical XLF files (one per translation domain) in app/Resources/translations/default
. This catalogue is to be filtered by keeping only the translation domains whose name starts with “Admin”.
Translations are retrieved from two sources:
app/Resources/translations/{locale_code}
, one per domain.If the same wording is translated in both core files and database, the database translation is shown.
This translation type has two different subcases:
i. If the user chooses “Core translations”.
The behavior is exactly like “back office translations”, only that translation domains are filtered by domains starting with “Shop” instead.
ii. If the user chooses a theme.
In this case, wordings are sourced by analyzing all the theme’s files. Since this process is slow, the result of this analysis is stored as XLF files in local filesystem cache. If the cache is found, then wordings are read from there. The user can refresh this cache by clicking on the “Find new wordings” button at the top of the page.
Translations are sourced exactly like if the user had chosen “Core translations”, then adding the ones from database translations starting with “Shop” and where “theme” is empty, then adding the XLF files within the theme in its translations/{locale_code}
directory, one per domain. Each catalog replaces the translations from the previous one. Catalogs must be loaded in this order:
Note: the core catalog must be filtered as to not include translations that are not used by the theme (otherwise you end up with all the Core translations).
User-edited translations are stored in database. To avoid collisions, theme translations must be kept associated to the theme they belong. If a theme redefines a Core translation (ie. same domain, same wording), then the redefined translation should only be used when the FO is using that theme (eg. in case of multishop with different themes for each shop, each theme should use the its own translation even if they both use the same given wording/domain pair). Redefined core translations should only be saved if they’re different than the ones defined when not in the theme’s context.
Note: modules have to opt-in for this feature (see documentation).
Wordings are pulled from a sequence of sources:
First, the Core’s default catalogue, which is stored as physical XLF files (one per translation domain) in app/Resources/translations/default
. This catalogue is to be filtered by keeping only the translation domains whose name starts with “Modules.Nameofthemodule”.
Note: this is the case of native modules which have their catalogue integrated in the core
If no file is found, then wordings are sourced by analyzing all the module’s files. Since this process is slow, the result of this analysis is stored as XLF files in local filesystem cache. If the cache is found, then wordings are read from there. The user can refresh this cache by clicking on the “Find new wordings” button at the top of the page.
Translations are retrieved from a list of sources:
app/Resources/translations/{locale_code}
, one per domain.translations/{locale_code}
directory, one per domain.translations/
directory, one per language code.If the module uses Core translations, they are not shown on this interface.
If the same wording is translated in the core, the module files and the database, the database translation is shown.
The behavior is exactly like “back office translations”, but using only the domain called “Emails.Subject”.
The behavior is exactly like “back office translations”, but using only the domain called “Emails.Body”.
After saving the translations, the email templates must be regenerated for the translated language.
The behavior is exactly like “back office translations”, but using only the domain called “messages”.
Each source mentioned in the previous parts represents a level in the translation workflow:
It works the same for the modules that have their own translation files:
This feature allows the user to export translations in a given language. The user is given a list of options to choose what kind of translations they want to export:
When the user clicks on “Export”, a zip file is generated and downloaded.
The generated zip filename pattern will be translations_export_{locale_code}.zip
The generated zip contains exported translation domains, stored as XLF files (one per domain), each one containing of all the domain’s wordings and their translation to the target language.
Note: If a given wording is not translated, then the original wording should be used as translation in the exported file.
The domains that are included in the export package depend on the combination of options chosen in the form, as described below.
Each translation type roughly matches the translation sources described in the “Translation sources & storage” section above:
The exported package should include all XLF files stored under a language directory, like so:
fr-FR
├── AdminActions.fr-FR.xlf
├── AdminAdvparametersFeature.fr-FR.xlf
├── AdminAdvparametersHelp.fr-FR.xlf
└── ...
Translations are sourced in the same way as specified in “Front office - theme”:
The catalogs are loaded and overridden in this order (the last one being the one that “wins” if it exists):
Note: this export may include core translation domains if they are used by the theme’s files. However, only the wordings used by the theme are to be included in the exported file.
The exported package should include all XLF files stored under a language directory, like so:
fr-FR
├── ShopMytheme.fr-FR.xlf
├── ShopNavigation.fr-FR.xlf
├── ShopNotificationsError.fr-FR.xlf
└── ...
Translations are sourced in the same way as specified in “Installed module translations”.
Note: this export may include core translation domains if they are used by the module’s files. However, only the wordings used by the module are to be included in the exported file.
The exported package should include all XLF files stored under a language directory, like so:
fr-FR
├── ModulesymoduleAdmin.fr-FR.xlf
├── ModuleMymoduleShop.fr-FR.xlf
├── ShopNotificationsError.fr-FR.xlf
└── ...
Exported XLF files should respect the following file name convention:
<DOMAIN_NAME>.<IETF_LTAG>.xlf
Where:
Composed example:
AdminAdvparametersFeature.es-MX.xlf