admin管理员组文章数量:1130349
I made a custom theme and wonder how could I extract all translatable strings to a .po file so I can translate it. Do I need WPML plugin?
Ex: I have a string "soccer" which is written as _e('soccer','mytheme'); and I want to translate it to "futebol" but how can I transport it to a .po file?
I made a custom theme and wonder how could I extract all translatable strings to a .po file so I can translate it. Do I need WPML plugin?
Ex: I have a string "soccer" which is written as _e('soccer','mytheme'); and I want to translate it to "futebol" but how can I transport it to a .po file?
- Check this post – Pieter Goosen Commented Jun 29, 2014 at 10:22
2 Answers
Reset to default 3One way is to use the WordPress i18n tools. I had to checkout WordPress trunk to make it work. On the command line:
svn co http://develop.svn.wordpress/trunk
once you have trunk somewhere, you'll then want to call the makepot script. Again, on the command line:
php /path/to/wordpress/trunk/tools/i18n/makepot.php wp-theme /path/to/your/theme/
After that script has run, the pot files will be in whatever directory was specified in the above /path/to/your/theme
More information and a couple of other methods can be seen here: http://codex.wordpress/I18n_for_WordPress_Developers
You can extract traslatable (gettext) strings from a Wordpress Theme or Plugin with wp-cli. To install:
- Visit oficial documentation.
- Use Homebrew (mac):
brew install wp-cli
Once you have it, you run the following command:
wp i18n . path/to/domain_name.pot --domain=domain_name
(Run from the theme/plugin root folder, where domain_name is the domain you've used on the code.)
This will generate a .pot file. You can use software like POEdit to open the .pot file and do the translations. This software will then let you export to .po and .mo.
You can find more info on I18n for Wordpress Developers.
I made a custom theme and wonder how could I extract all translatable strings to a .po file so I can translate it. Do I need WPML plugin?
Ex: I have a string "soccer" which is written as _e('soccer','mytheme'); and I want to translate it to "futebol" but how can I transport it to a .po file?
I made a custom theme and wonder how could I extract all translatable strings to a .po file so I can translate it. Do I need WPML plugin?
Ex: I have a string "soccer" which is written as _e('soccer','mytheme'); and I want to translate it to "futebol" but how can I transport it to a .po file?
- Check this post – Pieter Goosen Commented Jun 29, 2014 at 10:22
2 Answers
Reset to default 3One way is to use the WordPress i18n tools. I had to checkout WordPress trunk to make it work. On the command line:
svn co http://develop.svn.wordpress/trunk
once you have trunk somewhere, you'll then want to call the makepot script. Again, on the command line:
php /path/to/wordpress/trunk/tools/i18n/makepot.php wp-theme /path/to/your/theme/
After that script has run, the pot files will be in whatever directory was specified in the above /path/to/your/theme
More information and a couple of other methods can be seen here: http://codex.wordpress/I18n_for_WordPress_Developers
You can extract traslatable (gettext) strings from a Wordpress Theme or Plugin with wp-cli. To install:
- Visit oficial documentation.
- Use Homebrew (mac):
brew install wp-cli
Once you have it, you run the following command:
wp i18n . path/to/domain_name.pot --domain=domain_name
(Run from the theme/plugin root folder, where domain_name is the domain you've used on the code.)
This will generate a .pot file. You can use software like POEdit to open the .pot file and do the translations. This software will then let you export to .po and .mo.
You can find more info on I18n for Wordpress Developers.
本文标签: translationHow to extract translatable (double underscores and e) strings
版权声明:本文标题:translation - How to extract translatable (double underscores and _e) strings? 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749095718a2315221.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论