admin管理员组文章数量:1320165
I've had for a long time a site with the famous Recent Tweets Widget. The plugin came as part of a theme, and back in the day, it included translation .po and .mo files for French language. I didn't pay attention to this before.
But recently I have found that the strings indicating the tweet's age (x days/months ago, etc.) are translated into Spanish, main language of the site. I have confirmed that the translated strings are not in the .po files, neither from the plugin nor from the site translations. So I assume they come fron an external site. I couldn't tell the exact date when it happened.
Digging about this oddity, I've found that translations can now be managed in . And in this site, the aforementioned plugin exists, with 8 translations (a specially bad one for Spanish). My guess is somehow WP could be recovering this translation from the site, via REST API or similar. But I can't find any specific call for this in the code.
I wonder if the __() function has now the ability to recover external translations for a given text domain, or, in the shape of a question: what could be the possible sources for this "ghost" translation? Thanks in advance.
I've had for a long time a site with the famous Recent Tweets Widget. The plugin came as part of a theme, and back in the day, it included translation .po and .mo files for French language. I didn't pay attention to this before.
But recently I have found that the strings indicating the tweet's age (x days/months ago, etc.) are translated into Spanish, main language of the site. I have confirmed that the translated strings are not in the .po files, neither from the plugin nor from the site translations. So I assume they come fron an external site. I couldn't tell the exact date when it happened.
Digging about this oddity, I've found that translations can now be managed in http://translations.wordpress. And in this site, the aforementioned plugin exists, with 8 translations (a specially bad one for Spanish). My guess is somehow WP could be recovering this translation from the site, via REST API or similar. But I can't find any specific call for this in the code.
I wonder if the __() function has now the ability to recover external translations for a given text domain, or, in the shape of a question: what could be the possible sources for this "ghost" translation? Thanks in advance.
Share Improve this question asked Oct 13, 2020 at 20:00 maclmacl 1385 bronze badges1 Answer
Reset to default 1Yes, Recent Tweets Widget is one of the many plugins which their translations are managed through translate.wordpress, and this means that upon installing the plugin (*remember, installing and activating are different), WordPress (on your site) will automatically download the plugin's language pack (.po
and .mo
files) from translate.wordpress, and then store the translation files in the WordPress languages directory which defaults to wp-content/languages
.
But WordPress will only do that if a core/site language pack is found at wp-content/languages/<locale>.mo
(see get_available_languages()
), which in your case should be true — e.g. you might find the MO file at wp-content/languages/es_ES.mo
.
And for plugins, the downloaded language packs are saved to wp-content/languages/plugins/<locale>.<mo|po>
; so for example, the Recent Tweets Widget plugin where the text domain is recent-tweets-widget
, you'd find the translations for the Spanish (Spain) locale (es_ES
) in:
wp-content/languages/plugins/recent-tweets-widget-es_ES.mo
wp-content/languages/plugins/recent-tweets-widget-es_ES.po
Also, it should be noted that since WordPress 4.6, language pack found in the wp-content/languages/plugins
directory takes precedence over the one in the plugin's directory — which is normally loaded via load_plugin_textdomain()
— so with the Recent Tweets Widget plugin as an example, if you had both wp-content/languages/plugins/recent-tweets-widget-es_ES.mo
and wp-content/plugins/recent-tweets-widget/languages/recent-tweets-widget-es_ES.mo
, the former will be automatically loaded and be used instead of the latter.
Hence, I believe that MO file is the source of that "ghost" translation. :)
(Well if your site's locale is es_ES
, but even if not, try looking for one of the other Spanish locales. Then try renaming the file, e.g. <locale>.mo.bak
, and see if the "ghost" translation persists.)
Last but not least, when a plugin is deleted (and not simply deactivated), WordPress will also remove the plugin translation files in the wp-content/languages/plugins
, so keep that in mind if you wish to edit those files/translations.
Further Reading
- https://wordpress/support/wordpress-version/version-4-6/#highlights
- Translator’s Handbook » Plugin/Theme Authors Guide
- Plugin Author – Quick Reference Guide (on WP Info)
本文标签: Plugin translations not installed but strings are translated
版权声明:本文标题:Plugin translations not installed but... strings are translated! 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742061382a2418608.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论