admin管理员组文章数量:1122832
Using the wp i18n make-pot I can create a .pot
file that can interpret .php
files.
This is the command I use
wp i18n make-pot . languages/my-plugin.pot
This is good but because I use timber with my wordpress as its template engine, timber uses .twig
files.
How can I use wp-cli create .pot
command to look into .twig
files?
I tried this command
wp i18n make-pot . languages/my-plugin.pot --include=*.twig
That creates the same .pot
file that only interpreted .php
and not .twig
files as well.
Looking at github issues this is a open issue ease inheritance in order to support Twig/Timber.
Reading this thread I could not really come to a solution.
Using the wp i18n make-pot I can create a .pot
file that can interpret .php
files.
This is the command I use
wp i18n make-pot . languages/my-plugin.pot
This is good but because I use timber with my wordpress as its template engine, timber uses .twig
files.
How can I use wp-cli create .pot
command to look into .twig
files?
I tried this command
wp i18n make-pot . languages/my-plugin.pot --include=*.twig
That creates the same .pot
file that only interpreted .php
and not .twig
files as well.
Looking at github issues this is a open issue ease inheritance in order to support Twig/Timber.
Reading this thread I could not really come to a solution.
2 Answers
Reset to default 0As you mentioned - it's an open issue so unlikely to have been resolved by any of the solutions in the thread... This seems to be the most likely working solution though
wp timber make-pot && wp i18n make-pot --merge=twig.pot
I haven't used timber before but check what file is created with wp timber make-pot
and ensure that's the one merged into the i18n
command
The other code examples refer to improvements in the i18n-command
package itself
Edit
Looking at the ticket again this is actually just another "suggested" use case. But there's still hope...
According to this page on the timber GitHub support there are a few options available to you.
- Use a tool that supports parsing Twig files to detect all your translations like Poedit. This will make your
.pot
files and the merge command can be run to work it into thei18n
function. - A nasty twig vs. gettext hack is to add
{#<?php#}
to the top of your twig files. By doing this, gettext will interpret whatever comes next as PHP, and start looking for__
. - Twig gettext extractor - a special Twig parser for Poedit.
- There is mention of a gulp script to do this... however the links I followed don't seem to work any more - this is the original ticket for the gulp solution though and can be used as a base if you feel like having a crack at that
I had the same issue and located this package: timber/wp-i18n-twig https://packagist.org/packages/timber/wp-i18n-twig
After installing this package the wp i18n make-pot . languages/my-plugin.pot
worked on .twig files as well.
本文标签: translationUsing wpcli to create a pot file that interprets twig files as well
版权声明:本文标题:translation - Using wp-cli to create a .pot file that interprets .twig files as well 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736289269a1928270.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论