I'm building a plug-in which is going great so far. I want to start making it localization ready. I don't know what is going wrong, but it's bugging out on me when I try to load it in Poedit.
So let's do this step by step as multiple tutorials show me to.
So in myplugin.php I load the following to tell WP where my language files are (after actually creating the folder).
function ap_action_init()
{
// Localization
load_plugin_textdomain( 'myplugin', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
}
add_action('init', 'ap_action_init');
Then I adjust all strings that need translation in my file (which is in the admin folder).
<h2><?php _e('MyPlugin Settings', 'myplugin'); ?></h2>
<?php _e('Element Width', 'myplugin'); ?>
<?php _e('This defines the default width of your Elements', 'myplugin'); ?>
So far so good, I would think. But then I open Poedit.
I tell poedit to save the myplugin-nl_NL.po
in the languages folder in my plugin.
I tell the base path to be ../
And I tell my paths to be either ./admin
or admin
(if I give it /admin
, or something else, it gives me an error the folder doesn't exist. So I'm assuming it finds my folders).
I tell poedit to look for the keywords __()
and _e()
.
And then I press ok! Every single time (whatever I seem to try) It doesn't show me any strings to translate, where as I import a normal .po it does show me alot.
So. Is anyone seeing where it's going wrong here?
P.S: Maybe an important notice. If I try to manually create my own .po file, it does show me strings in POedit. But if I put this on my website and change WordPress it's language it doesn't change anything. So my guess is I'm doing something wrong in my WP files.
Hope anyone can help :)