Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I use the load_textdomain action hook to list all active localization text domains with corresponding path to translation files.

function mo_location( $domain, $mofile ) {  
    if ( !is_array($GLOBALS['moloc']) )
            $GLOBALS['moloc'] = array();

    $GLOBALS['moloc'][$domain] = $mofile;
}

add_action( 'load_textdomain', 'mo_location', 10, 2 );

For some reason the $domain variable is not filled with a "default" text domain values. Does anybody know why?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

The default text domain is registered in wp_load.php before plugins are loaded. See the function wp_load_translations_early().

So when you register your action callback, the text domain has been loaded already.

For an alternative way to list all registered text domains see this answer: List of Default Translated Phrases.

share|improve this answer
    
Yes, you are right! The thing is that I need cross reference domain with a corresponding translation file path. I use "must-use" plugin to initialize my code before all the translations are loaded. Do you think there is any better way? –  JohnnyPea Jan 14 '13 at 17:18
    
@JohnnyPea you cannot run custom code before wp_load_translations_early() is called. –  toscho Jan 14 '13 at 17:24
    
wp_load_translations_early() is not called during a regular load..."Designed for unusual load sequences (like setup-config.php) or for when the script will then terminate with an error, otherwise there is a risk that a file can be double-included." It's enough to run it before load_default_textdomain() on line 268 in wp-settings.php –  JohnnyPea Jan 14 '13 at 17:36
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.