admin管理员组文章数量:1279008
I'm working on plugin development and I'd like to localize my plugin name and description, so that these two pieces of information are shown to other WordPress developers in their native languages (if they are supported) on the list of currently installed plugins in WP Admin Dashboard. So far have I managed to accomplish this, but I've noticed that translations are not always shown. At example, if I disable my plugin, then the name and description are shown in original/english language, not in the matching the language of my WordPress instance.
For a second I've assumed that that's probably not even possible, but then I've noticed that the description of the plugin Hello Dolly (which is coming preinstalled and initially disabled) was shown in my language (Croatian to be exact). I've also tried to disable Akismet Anti-Spam plugin, whose description was as well shown in my language while it was enabled, and it remained translated in my language even after disablement.
Therefore my question is how to set-up plugin, so that its name and description are shown translated on the list of currently installed plugins in WP Admin Dashboard even when the plugin is disabled?
I'm working on plugin development and I'd like to localize my plugin name and description, so that these two pieces of information are shown to other WordPress developers in their native languages (if they are supported) on the list of currently installed plugins in WP Admin Dashboard. So far have I managed to accomplish this, but I've noticed that translations are not always shown. At example, if I disable my plugin, then the name and description are shown in original/english language, not in the matching the language of my WordPress instance.
For a second I've assumed that that's probably not even possible, but then I've noticed that the description of the plugin Hello Dolly (which is coming preinstalled and initially disabled) was shown in my language (Croatian to be exact). I've also tried to disable Akismet Anti-Spam plugin, whose description was as well shown in my language while it was enabled, and it remained translated in my language even after disablement.
Therefore my question is how to set-up plugin, so that its name and description are shown translated on the list of currently installed plugins in WP Admin Dashboard even when the plugin is disabled?
Share Improve this question asked Oct 4, 2021 at 17:28 zeko868zeko868 32 bronze badges 2 |1 Answer
Reset to default 0Hello Dolly is a specific edge case, it does not translate itself. Rather it's considered a part of the WordPress codebase, and has a translated title in the WP core language files.
Instead, to have a plugin name translated, you need a language file that maps to the textdomain
specified in your plugin, that contains your plugin name. This needs to be in the wp-content/languages/plugins
folder or in the appropriate location inside your plugin. e.g. for mytestplugin
it could be mytestplugin/mytextdomain-en_US.mo
where mytextdomain
is what you specified in your plugins header.
This is done via _get_plugin_data_markup_translate
( which has a special override for hello dolly ), and uses load_plugin_textdomain
.
本文标签: Use localized plugin name and description even when the plugin is disabled
版权声明:本文标题:Use localized plugin name and description even when the plugin is disabled 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741287329a2370346.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
Hello Dolly
and see how it does it? – vancoder Commented Oct 4, 2021 at 17:32