triveon / translate-custom-variables
一个模块,用于在可翻译的CMS字符串中使用自定义变量
1.1.1
2024-02-23 12:31 UTC
Requires
- php: >=7.3
This package is auto-updated.
Last update: 2024-09-23 14:23:41 UTC
README
这是官方的Translate Custom Variables Magento 2扩展。使用此模块,您可以在CMS元素的可翻译字符串中使用自定义变量。
它如何工作?
- 例如,您有一个自定义变量,代码为free_shipping_cost,您想在CMS块或CMS页面的可翻译字符串中放置它
- 为此,必须在翻译字符串中自定义变量代码之前放置前缀"customVar_"
- 如下:{{trans "Free Shipping from %free_shipping" free_shipping=customVar_free_shipping_cost}}
将用自定义变量free_shipping_cost的值替换%free_shipping。
安装
使用composer安装(推荐)
请使用SSH登录到您的环境。然后导航到Magento 2根目录,并按以下顺序运行以下命令
启用维护模式
php bin/magento maintenance:enable
- 安装扩展
composer require triveon/translate-custom-variables
- 启用Translate Custom Variables Magento 2插件
php bin/magento module:enable Triveon_TransCustomVars
- 更新Magento 2环境
php bin/magento setup:upgrade
当您的Magento环境在生产模式下运行时,您还需要运行以下命令
- 编译DI
php bin/magento setup:di:compile
- 部署静态内容
php bin/magento setup:static-content:deploy
- 禁用维护模式
php bin/magento maintenance:disable
手动安装
- 直接从github下载扩展,点击代码然后点击下载ZIP。
- 创建目录app/code/Triveon/TransCustomVars(大小写敏感)
- 解压zip并将代码上传到app/code/Triveon/TransCustomVars
- 启用Translate Custom Vars Magento 2插件
php bin/magento module:enable Triveon_TransCustomVars
- 更新Magento 2环境
php bin/magento setup:upgrade
更新
要更新Translate Custom Variables扩展,请运行以下命令
composer update triveon/translate-custom-variables php bin/magento setup:upgrade