Make WordPress Core


Ignore:
Timestamp:
09/11/2025 10:11:40 AM (5 months ago)
Author:
swissspidy
Message:

I18N: Use Domain Path for script translations if available.

This is a follow-up to [59461] from 6.8, which leveraged Domain Path for just-in-time loading of MO/PHP translation files.

Now, the same is done for script translations, which means plugins/themes shipping with their own translation no longer need to manually specify the translation path when calling wp_set_script_translations().

Props tusharbharti, swissspidy, shailu25, jsnajdr.
See #62244, #54797.
Fixes #63944.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/l10n.php

    r59719 r60728  
    11351135 * @see WP_Scripts::set_translations()
    11361136 *
     1137 * @global WP_Textdomain_Registry $wp_textdomain_registry WordPress Textdomain Registry.
     1138 *
    11371139 * @param string $handle Name of the script to register a translation domain to.
    11381140 * @param string $domain Optional. Text domain. Default 'default'.
     
    11421144 */
    11431145function load_script_textdomain( $handle, $domain = 'default', $path = '' ) {
     1146    /** @var WP_Textdomain_Registry $wp_textdomain_registry */
     1147    global $wp_textdomain_registry;
     1148
    11441149    $wp_scripts = wp_scripts();
    11451150
     
    11481153    }
    11491154
    1150     $path   = untrailingslashit( $path );
    11511155    $locale = determine_locale();
     1156
     1157    if ( ! $path ) {
     1158        $path = $wp_textdomain_registry->get( $domain, $locale );
     1159    }
     1160
     1161    $path = untrailingslashit( $path );
    11521162
    11531163    // If a path was given and the handle file exists simply return it.
Note: See TracChangeset for help on using the changeset viewer.