Woocommerce Multilingual issue, How to add and edi

2019-09-01 08:46发布

I am working on an multilingual e-Shop using Woocommerce. I downloaded the woocommerce .po and .mo, they work fine.

However, I added some custom content into some .php files. And there are some string that I want to translate.

E.g. I found the code in "templates/content-product.php" and the code is at line 64:

I get into the .po file. And added:

#: 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?

1条回答
女痞
2楼-- · 2019-09-01 09:08

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.

For example:

_e( 'Some sample text', 'my-text-domain' );

Then you will be able to generate mo/po files for the 'my-text-domain'.

Developer's Handbook on internationalizing plugins
Codex: i18n for WordPress Developers

查看更多
登录 后发表回答