• add_action('init', 'kfuk_widgets_load_translations');
    function kfuk_widgets_load_translations() {
    	load_plugin_textdomain('kfukwidgets', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/');
    }
    
    class kfuk_gift_widget extends \WP_Widget {
    	function __construct() {
    // snip:d for brevity
    	}
    
    	function widget($args, $instance) {
    		// output
    		__("this is a test", "kfukwidgets");
    	}
    
    	function update($new_instance, $old_instance) {
    // snip:d for brevity
    	}
    
    	function form($instance) {
    // snip:d for brevity
    	}
    }

    I have created a kfukwidgets-default.pot file, with POEdit, I then duplicated it, renamed it to kfukwidgets-sv_SE.po, I then translated the string in POEdit, which I then saved and it generated a kfukwidgets-sv_SE.mo file.

    But the translation won’t work even if get_locale() reports the very same locale I have defined in the file name.

  • The topic ‘load_plugin_textdomain driving me insane!’ is closed to new replies.