wpseek.com
A WordPress-centric search engine for devs and theme authors
load_textdomain › WordPress Function
Since1.5.0
Deprecatedn/a
› load_textdomain ( $domain, $mofile, $locale = null )
Parameters: (3) |
|
Returns: |
|
Defined at: |
|
Codex: | |
Change Log: |
|
Loads a .mo file into the text domain $domain.
If the text domain already exists, the translations will be merged. If both sets have the same string, the translation from the original value will be taken. On success, the .mo file will be placed in the $l10n global by $domain and will be a MO object.Related Functions: unload_textdomain, load_theme_textdomain, load_script_textdomain, load_plugin_textdomain, load_default_textdomain
Source
function load_textdomain( $domain, $mofile, $locale = null ) { /** @var WP_Textdomain_Registry $wp_textdomain_registry */ global $l10n, $l10n_unloaded, $wp_textdomain_registry; $l10n_unloaded = (array) $l10n_unloaded; /** * Filters whether to override the .mo file loading. * * @since 2.9.0 * @since 6.2.0 Added the `$locale` parameter. * * @param bool $override Whether to override the .mo file loading. Default false. * @param string $domain Text domain. Unique identifier for retrieving translated strings. * @param string $mofile Path to the MO file. * @param string|null $locale Locale. */ $plugin_override = apply_filters( 'override_load_textdomain', false, $domain, $mofile, $locale ); if ( true === (bool) $plugin_override ) { unset( $l10n_unloaded[ $domain ] ); return true; } /** * Fires before the MO translation file is loaded. * * @since 2.9.0 * * @param string $domain Text domain. Unique identifier for retrieving translated strings. * @param string $mofile Path to the .mo file. */ do_action( 'load_textdomain', $domain, $mofile ); /** * Filters MO file path for loading translations for a specific text domain. * * @since 2.9.0 * * @param string $mofile Path to the MO file. * @param string $domain Text domain. Unique identifier for retrieving translated strings. */ $mofile = apply_filters( 'load_textdomain_mofile', $mofile, $domain ); if ( ! is_readable( $mofile ) ) { return false; } if ( ! $locale ) { $locale = determine_locale(); } $mo = new MO(); if ( ! $mo->import_from_file( $mofile ) ) { $wp_textdomain_registry->set( $domain, $locale, false ); return false; } if ( isset( $l10n[ $domain ] ) ) { $mo->merge_with( $l10n[ $domain ] ); } unset( $l10n_unloaded[ $domain ] ); $l10n[ $domain ] = &$mo; $wp_textdomain_registry->set( $domain, $locale, dirname( $mofile ) ); return true; }