This is the official Translate Custom Variables Magento 2 extension. With this module it is possible to use custom variables in translatable strings in CMS elements.
- For example, you have a custom variable with code free_shipping_cost, and you want to place it in a translatable string in a CMS Block or CMS Page
- To do this, the prefix "customVar_" must be placed before the custom variable code in the translation string
- As: {{trans "Free Shipping from %free_shipping" free_shipping=customVar_free_shipping_cost}}
The %free_shipping will be replaced by the value from the custom variable free_shipping_cost.
To install the extension login to your environment using SSH. Then navigate to the Magento 2 root directory and run the following commands in the same order as described:
Enable maintenance mode:
php bin/magento maintenance:enable
- Install the extension:
composer require triveon/translate-custom-variables
- Enable the Translate Custom Variables Magento 2 plugin
php bin/magento module:enable Triveon_TransCustomVars
- Update the Magento 2 environment:
php bin/magento setup:upgrade
When your Magento environment is running in production mode, you also need to run the following comands:
- Compile DI:
php bin/magento setup:di:compile
- Deploy static content:
php bin/magento setup:static-content:deploy
- Disable maintenance mode:
php bin/magento maintenance:disable
- Download the extension directly from github by clicking on Code and then Download ZIP.
- Create the directory app/code/Triveon/TransCustomVars (Case-sensitive)
- Extract the zip and upload the code into app/code/Triveon/TransCustomVars
- Enable the Translate Custom Vars Magento 2 plugin
php bin/magento module:enable Triveon_TransCustomVars
- Update the Magento 2 environment:
php bin/magento setup:upgrade
To update the Translate Custom Variables Extension run the following commands:
composer update triveon/translate-custom-variables
php bin/magento setup:upgrade