diff --git src/wp-includes/class.wp-scripts.php src/wp-includes/class.wp-scripts.php
index e843233cbc..00a1d00aad 100644
|
|
class WP_Scripts extends WP_Dependencies { |
499 | 499 | * Sets a translation textdomain. |
500 | 500 | * |
501 | 501 | * @since 5.0.0 |
| 502 | * @since 5.0.3 The `$domain` parameter was made optional. |
502 | 503 | * |
503 | 504 | * @param string $handle Name of the script to register a translation domain to. |
504 | | * @param string $domain The textdomain. |
| 505 | * @param string $domain Optional. Text domain. Default 'default'. |
505 | 506 | * @param string $path Optional. The full file path to the directory containing translation files. |
506 | 507 | * |
507 | 508 | * @return bool True if the textdomain was registered, false if not. |
508 | 509 | */ |
509 | | public function set_translations( $handle, $domain, $path = null ) { |
| 510 | public function set_translations( $handle, $domain = 'default', $path = null ) { |
510 | 511 | if ( ! isset( $this->registered[ $handle ] ) ) { |
511 | 512 | return false; |
512 | 513 | } |
… |
… |
class WP_Scripts extends WP_Dependencies { |
517 | 518 | if ( ! in_array( 'wp-i18n', $obj->deps, true ) ) { |
518 | 519 | $obj->deps[] = 'wp-i18n'; |
519 | 520 | } |
| 521 | |
520 | 522 | return $obj->set_translations( $domain, $path ); |
521 | 523 | } |
522 | 524 | |
diff --git src/wp-includes/functions.wp-scripts.php src/wp-includes/functions.wp-scripts.php
index 5aa26cca5e..2302433942 100644
|
|
function wp_localize_script( $handle, $object_name, $l10n ) { |
209 | 209 | * @global WP_Scripts $wp_scripts The WP_Scripts object for printing scripts. |
210 | 210 | * |
211 | 211 | * @since 5.0.0 |
| 212 | * @since 5.0.3 The `$domain` parameter was made optional. |
212 | 213 | * |
213 | 214 | * @param string $handle Script handle the textdomain will be attached to. |
214 | | * @param string $domain The textdomain. |
| 215 | * @param string $domain Optional. Text domain. Default 'default'. |
215 | 216 | * @param string $path Optional. The full file path to the directory containing translation files. |
216 | 217 | * |
217 | 218 | * @return bool True if the textdomain was successfully localized, false otherwise. |
218 | 219 | */ |
219 | | function wp_set_script_translations( $handle, $domain, $path = null ) { |
| 220 | function wp_set_script_translations( $handle, $domain = 'default', $path = null ) { |
220 | 221 | global $wp_scripts; |
221 | 222 | if ( ! ( $wp_scripts instanceof WP_Scripts ) ) { |
222 | 223 | _wp_scripts_maybe_doing_it_wrong( __FUNCTION__ ); |
diff --git src/wp-includes/l10n.php src/wp-includes/l10n.php
index 7dd86607ec..8bdd5754c4 100644
|
|
function load_child_theme_textdomain( $domain, $path = false ) { |
898 | 898 | * |
899 | 899 | * @since 5.0.0 |
900 | 900 | * @since 5.0.2 Uses load_script_translations() to load translation data. |
| 901 | * @since 5.0.3 The `$domain` parameter was made optional. |
901 | 902 | * |
902 | 903 | * @see WP_Scripts::set_translations() |
903 | 904 | * |
904 | 905 | * @param string $handle Name of the script to register a translation domain to. |
905 | | * @param string $domain The text domain. |
| 906 | * @param string $domain Optional. Text domain. Default 'default'. |
906 | 907 | * @param string $path Optional. The full file path to the directory containing translation files. |
907 | 908 | * |
908 | 909 | * @return false|string False if the script textdomain could not be loaded, the translated strings |
909 | 910 | * in JSON encoding otherwise. |
910 | 911 | */ |
911 | | function load_script_textdomain( $handle, $domain, $path = null ) { |
| 912 | function load_script_textdomain( $handle, $domain = 'default', $path = null ) { |
912 | 913 | $wp_scripts = wp_scripts(); |
913 | 914 | |
914 | 915 | if ( ! isset( $wp_scripts->registered[ $handle ] ) ) { |
diff --git src/wp-includes/script-loader.php src/wp-includes/script-loader.php
index 2772ab6eb8..17c8042911 100644
|
|
function wp_default_packages_scripts( &$scripts ) { |
466 | 466 | ); |
467 | 467 | |
468 | 468 | $package_translations = array( |
469 | | 'api-fetch' => 'default', |
470 | | 'blocks' => 'default', |
471 | | 'block-library' => 'default', |
472 | | 'components' => 'default', |
473 | | 'edit-post' => 'default', |
474 | | 'editor' => 'default', |
475 | | 'format-library' => 'default', |
476 | | 'keycodes' => 'default', |
477 | | 'list-reusable-blocks' => 'default', |
478 | | 'nux' => 'default', |
| 469 | 'api-fetch', |
| 470 | 'blocks', |
| 471 | 'block-library', |
| 472 | 'components', |
| 473 | 'edit-post', |
| 474 | 'editor', |
| 475 | 'format-library', |
| 476 | 'keycodes', |
| 477 | 'list-reusable-blocks', |
| 478 | 'nux', |
479 | 479 | ); |
480 | 480 | |
481 | 481 | foreach ( $packages_dependencies as $package => $dependencies ) { |
… |
… |
function wp_default_packages_scripts( &$scripts ) { |
485 | 485 | |
486 | 486 | $scripts->add( $handle, $path, $dependencies, $version, 1 ); |
487 | 487 | |
488 | | if ( isset( $package_translations[ $package ] ) ) { |
489 | | $scripts->set_translations( $handle, $package_translations[ $package ] ); |
| 488 | if ( in_array( $package, $package_translations, true ) ) { |
| 489 | $scripts->set_translations( $handle ); |
490 | 490 | } |
491 | 491 | } |
492 | 492 | } |