diff --git src/wp-includes/l10n.php src/wp-includes/l10n.php
index d1afbe4832..0af61ebdf7 100644
|
|
|
function load_script_textdomain( $handle, $domain, $path = null ) { |
| 895 | 895 | $file_base = $domain === 'default' ? $locale : $domain . '-' . $locale; |
| 896 | 896 | $handle_filename = $file_base . '-' . $handle . '.json'; |
| 897 | 897 | if ( $path && file_exists( $path . '/' . $handle_filename ) ) { |
| 898 | | return file_get_contents( $path . '/' . $handle_filename ); |
| | 898 | return load_script_translation( $path . '/' . $handle_filename, $handle, $domain ); |
| 899 | 899 | } |
| 900 | 900 | |
| 901 | 901 | $obj = $wp_scripts->registered[ $handle ]; |
| … |
… |
function load_script_textdomain( $handle, $domain, $path = null ) { |
| 935 | 935 | |
| 936 | 936 | // If the source is not from WP. |
| 937 | 937 | if ( false === $relative ) { |
| 938 | | return false; |
| | 938 | return load_script_translation( false, $handle, $domain ); |
| 939 | 939 | } |
| 940 | 940 | |
| 941 | 941 | // Translations are always based on the unminified filename. |
| … |
… |
function load_script_textdomain( $handle, $domain, $path = null ) { |
| 945 | 945 | |
| 946 | 946 | $md5_filename = $file_base . '-' . md5( $relative ) . '.json'; |
| 947 | 947 | if ( $path && file_exists( $path . '/' . $md5_filename ) ) { |
| 948 | | return file_get_contents( $path . '/' . $md5_filename ); |
| | 948 | return load_script_translation( $path . '/' . $md5_filename, $handle, $domain ); |
| 949 | 949 | } |
| 950 | 950 | if ( file_exists( $languages_path . '/' . $md5_filename ) ) { |
| 951 | | return file_get_contents( $languages_path . '/' . $md5_filename ); |
| | 951 | return load_script_translation( $languages_path . '/' . $md5_filename, $handle, $domain ); |
| 952 | 952 | } |
| 953 | 953 | |
| 954 | | return false; |
| | 954 | return load_script_translation( false, $handle, $domain ); |
| | 955 | } |
| | 956 | |
| | 957 | /** |
| | 958 | * Load the translated strings for the given script handle and textdomain. |
| | 959 | * |
| | 960 | * @since 5.0.0 |
| | 961 | * |
| | 962 | * @param string|false $file Path to the translation file to load. False if there isn't one. |
| | 963 | * @param string $handle Name of the script to register a translation domain to. |
| | 964 | * @param string $domain The textdomain. |
| | 965 | * @return string|false The JSON-encoded translated strings for the given script handle and textdomain. False if there are none. |
| | 966 | */ |
| | 967 | function load_script_translation( $file, $handle, $domain ) { |
| | 968 | /** |
| | 969 | * Filters the file path for loading script translations for the given script handle and textdomain. |
| | 970 | * |
| | 971 | * @since 5.0.0 |
| | 972 | * |
| | 973 | * @param string|false $file Path to the translation file to load. False if there isn't one. |
| | 974 | * @param string $handle Name of the script to register a translation domain to. |
| | 975 | * @param string $domain The textdomain. |
| | 976 | */ |
| | 977 | $file = apply_filters( 'load_script_textdomain_file', $file, $handle, $domain ); |
| | 978 | |
| | 979 | if ( ! $file || ! is_readable( $file ) ) { |
| | 980 | return false; |
| | 981 | } |
| | 982 | |
| | 983 | return file_get_contents( $file ); |
| 955 | 984 | } |
| 956 | 985 | |
| 957 | 986 | /** |