meta-box in the "themes folder" language settings
- This topic has 5 replies, 3 voices, and was last updated 7 years, 6 months ago by
Anh Tran.
-
AuthorPosts
-
August 28, 2016 at 7:38 PM #3954
eboss99s
ParticipantI 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.August 31, 2016 at 2:19 PM #3968Anh Tran
KeymasterHi,
Do you mean including the plugin inside theme doesn't load the translation?
April 19, 2018 at 7:46 AM #9266Teia Local Studio
ParticipantHello, 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.April 19, 2018 at 8:32 AM #9267Anh Tran
KeymasterHi,
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
languagesfile 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 😉
April 19, 2018 at 5:58 PM #9281Teia Local Studio
ParticipantOh!
So it works if I call it directly on my theme?
Fantastic. Didn't try it before.Thanks, Ahn.
Always thanks.G.
April 20, 2018 at 3:18 PM #9294Anh Tran
KeymasterYes, that should work. There's no difference where we put the code. It's just the code :D.
-
AuthorPosts
- The topic ‘meta-box in the "themes folder" language settings’ is closed to new replies.