wp-includes/l10n.php:1208Resolves and loads the translation JSON file for a given script or script module source URL.
$handlestring$srcstring$domainstring$pathstring$is_moduleboolstring|falseOne hook fires while _load_script_textdomain_from_src() runs, in this order:
Filters the relative path of scripts used for finding translation files.
function _load_script_textdomain_from_src( string $handle, string $src, string $domain, string $path, bool $is_module ) { /** @var WP_Textdomain_Registry $wp_textdomain_registry */ global $wp_textdomain_registry; $locale = determine_locale(); if ( ! $path ) { $path = $wp_textdomain_registry->get( $domain, $locale ); } if ( $path ) { $path = untrailingslashit( $path ); } // If a path was given and the handle file exists simply return it. $file_base = 'default' === $domain ? $locale : $domain . '-' . $locale; $handle_filename = $file_base . '-' . $handle . '.json'; if ( $path ) { $translations = load_script_translations( $path . '/' . $handle_filename, $handle, $domain ); if ( $translations ) { return $translations; } } $relative = false; $languages_path = WP_LANG_DIR; $src_url = wp_parse_url( $src ); if ( ! $src_url ) { return load_script_translations( false, $handle, $domain ); } $src_url['path'] ??= ''; $content_url = wp_parse_url( content_url() ); if ( ! $content_url ) { return load_script_translations( false, $handle, $domain ); } $plugins_url = wp_parse_url( plugins_url() ); $site_url = wp_parse_url( site_url() ); $theme_root = get_theme_root(); // If the host is the same or it's a relative URL. if ( ( ! isset( $content_url['path'] ) || str_starts_with( $src_url['path'], $content_url['path'] ) ) && ( ! isset( $src_url['host'] ) || ! isset( $content_url['host'] ) || $src_url['host'] === $content_url['host'] ) ) { // Make the src relative the specific plugin or theme. if ( isset( $content_url['path'] ) ) { $relative = substr( $src_url['path'], strlen( $content_url['path'] ) ); } else { $relative = $src_url['path']; } $relative = trim( $relative, '/' ); $relative = explode( '/', $relative ); /* * Ensure correct languages path when using a custom `WP_PLUGIN_DIR` / `WP_PLUGIN_URL` configuration, * a custom theme root, and/or using Multisite with subdirectories. * See https://core.trac.wordpress.org/ticket/60891 and https://core.trac.wordpress.org/ticket/62016. */ $theme_dir = array_slice( explode( '/', $theme_root ), -1 ); $dirname = $theme_dir[0] === $relative[0] ? 'themes' : 'plugins'; $languages_path = WP_LANG_DIR . '/' . $dirname; $relative = array_slice( $relative, 2 ); // Remove plugins/<plugin name> or themes/<theme name>. $relative = implode( '/', $relative ); } elseif ( ( ! isset( $plugins_url['path'] ) || str_starts_with( $src_url['path'], $plugins_url['path'] ) ) && ( ! isset( $src_url['host'] ) || ! isset( $plugins_url['host'] ) || $src_url['host'] === $plugins_url['host'] ) ) { // Make the src relative the specific plugin. if ( isset( $plugins_url['path'] ) ) { $relative = substr( $src_url['path'], strlen( $plugins_url['path'] ) ); } else { $relative = $src_url['path'];Introduced in 7.0.0. Unchanged from 7.0.4 through 7.1.0.
Signature, return type and hooks compared across 2 parsed releases.
src/wp-includes/l10n.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.