在 Prestashop 1.7 中使用变量翻译文本
Translating text with variable in Prestashop 1.7
尝试将字符串 There is %product_count% item in your cart.
翻译成 Il y a %products_count% article dans votre panier
时,我在前端得到了 Il y a %products_count% article dans votre panier
。就好像 %products_count%
被看作是一个字符串。
谢谢
在您的模板中试试这个:
{l s='There is %s item in your cart.' sprintf=[$product_count] mod='mymodule'}
Try this in your template:
{l s='There is %s item in your cart.' sprintf=[$product_count] mod='mymodule'}
- s=" " - 翻译您的文字
- %s - 你的翻译变量
- sprintf=[$your_variable] - 您的变量将显示在您的
字符串
- mod='mymodule' - 您的 module
的名称
完成后登录后台并执行以下步骤:
- 转到“国际”菜单下的“翻译”页面,
- 在“修改翻译”部分,找到“翻译类型”
下拉列表和 select “已安装 mod 规则翻译”,
- 选择您要翻译的mod规则。 (示例中的名称是“mymodule”,将其更改为您的 module 名称)
- 选择要将 mod 规则翻译成的语言。这
必须已安装目标语言才能启用翻译
在里面。
- 点击“修改”按钮。
完成这些步骤后,presta 应该会在您的 module 中生成“translatioins”文件。
来源:
https://devdocs.prestashop.com/1.7/modules/creation/module-translation/classic-system/
尝试将字符串 There is %product_count% item in your cart.
翻译成 Il y a %products_count% article dans votre panier
时,我在前端得到了 Il y a %products_count% article dans votre panier
。就好像 %products_count%
被看作是一个字符串。
谢谢
在您的模板中试试这个:
{l s='There is %s item in your cart.' sprintf=[$product_count] mod='mymodule'}
Try this in your template:
{l s='There is %s item in your cart.' sprintf=[$product_count] mod='mymodule'}
- s=" " - 翻译您的文字
- %s - 你的翻译变量
- sprintf=[$your_variable] - 您的变量将显示在您的 字符串
- mod='mymodule' - 您的 module 的名称
完成后登录后台并执行以下步骤:
- 转到“国际”菜单下的“翻译”页面,
- 在“修改翻译”部分,找到“翻译类型” 下拉列表和 select “已安装 mod 规则翻译”,
- 选择您要翻译的mod规则。 (示例中的名称是“mymodule”,将其更改为您的 module 名称)
- 选择要将 mod 规则翻译成的语言。这 必须已安装目标语言才能启用翻译 在里面。
- 点击“修改”按钮。
完成这些步骤后,presta 应该会在您的 module 中生成“translatioins”文件。
来源: https://devdocs.prestashop.com/1.7/modules/creation/module-translation/classic-system/