Support Forum
I have translated meta-box.
Using meta-box, placed in the "plugins folder" and then enabled, meta-box can show my national language (zh-TW), but the meta-box placed in the "themes folder" and then set displayed for the English language.
The use of normal, only the language is not displayed correctly, how to ask to be set.
Hi,
Do you mean including the plugin inside theme doesn't load the translation?
Hello, Ahn!
Sorry for bumping a old topic, but instead of opening a new one with same content, I thought it could be smart to write here.
YES.
I have the same problem when including it from a "plugins" folder INSIDE my theme.
To fix it, in CORE.PHP I need to change from:
load_plugin_textdomain( 'meta-box', false, plugin_basename( RWMB_DIR ) . '/languages/' );
To:
load_textdomain( 'meta-box', plugin_basename( RWMB_DIR ) . '/languages/meta-box-'.get_locale().'.mo' );
So, every time I update the Meta Box plugin, I need to fix this again.
Any ideas?
Thanks, Ahn!
G.
EDIT:
Whoooops... Just saw now this topic was posted on MB-USER-META.
I was referring to the root META-BOX plugin.
Hi,
The problem with this method is the translation files are not loaded from translate.wordpress.org. It works only with local translation files which are included directly inside the plugin. The translation from translate.wordpress.org is preferred since it allows users to contribute easily and distribute more reliably. Besides, it has a higher priority, meaning if a language is available on both translate.wordpress.org and inside plugin, the file from translate.wordpress.org is loaded.
For example, this is the translation page for Meta Box in Vietnamese:
https://translate.wordpress.org/locale/vi/default/wp-plugins/meta-box
Translation files from translate.wordpress.org are stored in wp-content/languages/plugins/meta-box/
and are regularly updated when new translations available.
Ideally, I'd love to remove the languages
file from the plugin, so only translations from translate.wordpress.org are used. At the moment, some languages are not available on translate.wordpress.org yet.
In your case, in order to make it work with your theme without modifying the plugin, you can add this line directly into your theme:
load_textdomain( 'meta-box', plugin_basename( RWMB_DIR ) . '/languages/meta-box-'.get_locale().'.mo' );
It works the same way 😉
Oh!
So it works if I call it directly on my theme?
Fantastic. Didn't try it before.
Thanks, Ahn.
Always thanks.
G.
Yes, that should work. There's no difference where we put the code. It's just the code :D.