Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Plugin API/Action Reference/load textdomain


load_textdomain is triggered just before the .mo file is loaded for translation when the function load_textdomain() is called either directly or via load_plugin_textdomain() by a plugin or load_theme_textdomain() by a theme. These two functions, in turn are wrappers for load_textdomain().


<?php add_action( 'load_textdomain', 'function_name' ); ?>

where "function_name" is the name of the function to be called.


(string) (required) The unique identifier for retrieving translated strings. For eg, for a particular plugin or theme.
Default: None
(string) (required) Path to the .mo file.
Default: None


 * Example of load_textdomain usage
 * @param string $domain Unique domain for translation.
 * @param string $mofile Path to the .mo file.
 * @param array|string $args Optional args used in taxonomy registration.

function log_mo_file_load($domain, $mofile){
    echo 'loading file "' . $mofile . '" on domain "' . $domain . '"';
    // or whatever else you'd like to do here.

add_action( 'load_textdomain', 'log_mo_file_load' );


Source File

The load_textdomain hook is found in wp-includes/l10n.php within the load_textdomain() function.