在我正在开发的插件中,大多数翻译都可以工作,但有些字符串在没有明显原因的情况下拒绝工作。
对于设置页面,我使用以下模式:
$clgs_settings_descriptions = array(
\'notification_severity_filter\' => __( \'Minimum severity for notification in adminstration menu\', \'custom-logging-service\' ),
\'def_severity_filter\' => __( \'Default minimum severity filter on log page\', \'custom-logging-service\' ),
\'manager_role\' => __( \'Roles that can manage Custom Logs\', \'custom-logging-service\' ),
\'log_entries_per_page\' => __( \'Log entries per page\', \'custom-logging-service\' )
);
function clgs_settings_init() {
global $clgs_settings_descriptions;
//..
foreach ( $clgs_settings_descriptions as $key => $desc ) {
add_settings_field(
$key,
$desc,
\'clgs_field_render\',
CLGS_OPTION_PAGE,
CLGS_GROUP,
[ $key ]
);
}
}
add_action( \'admin_init\', \'clgs_settings_init\' );
这四个字符串位于custom-logging-service-de\\u de.po文件中:
#: includes/settings.php:3
msgid "Minimum severity for notification in adminstration menu"
msgstr "Mindestschweregrad für Benachrichtigungen im Administrationsmenü"
#: includes/settings.php:4
msgid "Default minimum severity filter on log page"
msgstr "Standard-Mindestschweregrad auf Log-Seite"
#: includes/settings.php:5
msgid "Roles that can manage Custom Logs"
msgstr "Rollen mit der Fähigkeit, Freie Logs zu verwalten"
#: includes/settings.php:6
msgid "Log entries per page"
msgstr "Log-Einträge pro Seite"
的。mo文件为当前文件。同一文件中还有其他可翻译字符串,如果我更改它们并运行gettext堆栈,我可以看到这些翻译出现在呈现页面中。
只有这四个字符串没有被翻译。
有人能看出他们为什么不工作吗?
Update 2016-2-3: 作为补丁,我现在打电话add_settings_field
像这样:
add_settings_field(
$key,
__( $desc, \'custom-logging-service\' ),
\'clgs_field_render\',
CLGS_OPTION_PAGE,
CLGS_GROUP,
[ $key ]
);
这是可行的,但我不会说这是预期的模式。