admin管理员组文章数量:1301534
I am using Mpdf lib to generate PDF for the plugin I am developing. The PDF has much more tabular data that require localization.
For that, I have created a function for TH
and TD
as below.
function gs_pdf_th(string $text, $style = FALSE, string $class = 'header')
{
return '<th class="' . $class . '" ' . $style . '>' . __($text, 'group-shop') . '</th>';
}
This function's problem is PO
is not detecting the $text
string for localization. All other text from the file where I used this function has been detected, but this one.
I am using Mpdf lib to generate PDF for the plugin I am developing. The PDF has much more tabular data that require localization.
For that, I have created a function for TH
and TD
as below.
function gs_pdf_th(string $text, $style = FALSE, string $class = 'header')
{
return '<th class="' . $class . '" ' . $style . '>' . __($text, 'group-shop') . '</th>';
}
This function's problem is PO
is not detecting the $text
string for localization. All other text from the file where I used this function has been detected, but this one.
- wordpress.stackexchange/questions/241589/… – cjbj Commented Mar 16, 2021 at 8:22
1 Answer
Reset to default 0You can’t use variables in translation functions. From the internationalisation documentation:
The following example tells you what not to do
// This is incorrect do not use. _e( "Your city is $city.", 'my-theme' );
The strings for translation are extracted from the source without executing the PHP associated with it. For example: The variable
$city
may be Vancouver, so your string will read"Your city is Vancouver"
when the template is run but gettext won’t know what is inside the PHP variable in advance.
You need to put the value in the translation function when initially defining it.
本文标签: localizationLanguage string not detecting used within the function
版权声明:本文标题:localization - Language string not detecting used within the function 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741678644a2392035.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论