Woocommerce多语言问题,如何添加和编辑字符串. [英] Woocommerce Multilingual issue, How to add and edit string.
问题描述
我正在使用Woocommerce开发多语言的电子商店.我下载了woocommerce .po和.mo,它们可以正常工作.
I am working on an multilingual e-Shop using Woocommerce. I downloaded the woocommerce .po and .mo, they work fine.
但是,我在一些.php文件中添加了一些自定义内容. 还有一些我想翻译的字符串.
However, I added some custom content into some .php files. And there are some string that I want to translate.
例如我在"templates/content-product.php"中找到了代码,并且代码在第64行:
E.g. I found the code in "templates/content-product.php" and the code is at line 64:
我进入.po文件. 并添加:
I get into the .po file. And added:
#:templates/content-product.php:64 msgstr查看产品" msgstr查看产品"
#: templates/content-product.php:64 msgid "View Product" msgstr "查看產品"
但是它不起作用. 如何检查确切的代码行使其起作用?
But it doesn't work. How to check the exact line of code to make it works?
推荐答案
您应该将模板文件复制到主题的WooCommerce文件夹中.然后,如果您修改字符串,请在自定义文本域中使用gettext()
函数.
You should copy template files into your theme's WooCommerce folder. And then if you modify strings, use the gettext()
functions with a custom text domain.
例如:
_e( 'Some sample text', 'my-text-domain' );
然后,您将能够为我的文本域"生成mo/po文件.
Then you will be able to generate mo/po files for the 'my-text-domain'.
关于插件国际化的开发人员手册
法典:适用于WordPress开发人员的i18n
这篇关于Woocommerce多语言问题,如何添加和编辑字符串.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!