• Resolved datainterlock

    (@datainterlock)


    I’m using code from the plugin boilerplate

    public function load_plugin_textdomain() {
    		$domain = $this->plugin_slug;
    		$locale = apply_filters( 'plugin_locale', get_locale(), $domain );
    
    		load_textdomain( $domain, trailingslashit( WP_LANG_DIR ) . $domain . '/' . $domain . '-' . $locale . '.mo' );
    		load_plugin_textdomain( $domain, FALSE, basename( plugin_dir_path( dirname( __FILE__ ) ) ) . '/languages/' );
    
    	}

    I’ve created es_ES.po and .mo files and they look good. Poedit is set to compile automatically. I’ve changed the language in my config.php to es_ES. I’ve downloaded the WordPress 3.9 es update. I’ve check paths, file names, and I’m about to pull out what little hair I have left.

    1. It did NOT move my language files when I upgraded WordPress to 3.9 es so the load_textdomain isn’t finding them in the new /language/ directory. Why it didn’t move them, I have no idea.

    2. load_plugin_textdomain does nothing. it’s still constantly in English no matter what I do.

    3. I’ve read the codex, other websites and a few religious pamphlets and STILL can’t get the language to load.

    any ideas?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter datainterlock

    (@datainterlock)

    Just in case someone else runs into this minor nightmare…

    the .po and .mo files must begin with the exact text domain… EXACT.

    load_textdomain( $domain ) – the $domain must be the EXACT same as the text domain

    and finally

    any __(‘junk’,’text_domain’) the text domain must be EXACTLY the same as all the others. Otherwise, you won’t load.

    I found this chunk of code to help test it and show me where I went wrong.

    $loaded = load_plugin_textdomain( 'text_domain', FALSE, basename( plugin_dir_path( dirname( __FILE__ ) ) ) . '/languages/' );
    	    if ( ! $loaded ){
                   echo "<hr/>";
    			   echo "Error: the mo file was not found! ";
    			   exit();
    
            }else{
    
                   echo "<hr/>Debug info:<br/>";
                   echo "WPLANG: ". WPLANG;
                   echo "<br/>";
                   echo "translate test: ". __('Some text','text_domain');
                   exit();
           }
    Aaron T. Grogg

    (@aarontgrogg)

    So… this is resolved, or no?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Plugin not loading language files’ is closed to new replies.