Ok i built plugin for contact form, I wanna add translation for it. In my main plugin files i add this code
function ap_action_init() {
// Localization
load_plugin_textdomain('prijava_forma', false, dirname(plugin_basename(__FILE__))."/languages";
}
// Add actions
add_action('init', 'ap_action_init');
in my file where contact form is written i have this
_e( 'Prva','prijava_forma' );
In my language folder I added the .mo and .po files created with Poedit.
Also I defined WPLANG
in config.php and changed the language in the dashboard.
But i get no translation. Where could be problem, i am new to this?
There are many possible causes:
myplugin-ru_RU.mo
Check what load_plugin_textdomain() returned, if the .mo file was loaded, it should return true, in which case the next step would be to check that you are not missing the textdomain parameter in your
__()
,_e()
and similar functions.More on WordPress localization
It may be also caused on hook where the functions is attached and where are the po/mo files.
On the Init Hooks,
load_plugin_textdomain()
returnedtrue
but string were not translated.I changed the action to
plugins_loaded
as my po/mo were in a folder inside a Custom plugins.Also make sure that your string stands for itself. Do not append anything to the string, do this after the
gettext
function instead.Wrong:
Right: