- Timestamp:
- 12/18/2018 11:41:35 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/5.0 merged: 44232
- Property svn:mergeinfo changed
-
trunk/src/wp-includes/l10n.php
r44310 r44316 895 895 896 896 /** 897 * Load the script translated strings. 897 * Loads the script translated strings. 898 * 899 * @since 5.0.0 900 * @since 5.0.2 Uses load_script_translations() to load translation data. 898 901 * 899 902 * @see WP_Scripts::set_translations() 900 * @link https://core.trac.wordpress.org/ticket/45103901 * @global WP_Scripts $wp_scripts The WP_Scripts object for printing scripts.902 *903 * @since 5.0.0904 903 * 905 904 * @param string $handle Name of the script to register a translation domain to. 906 * @param string $domain The text domain.905 * @param string $domain The text domain. 907 906 * @param string $path Optional. The full file path to the directory containing translation files. 908 907 * … … 911 910 */ 912 911 function load_script_textdomain( $handle, $domain, $path = null ) { 913 global $wp_scripts;912 $wp_scripts = wp_scripts(); 914 913 915 914 if ( ! isset( $wp_scripts->registered[ $handle ] ) ) { … … 924 923 $handle_filename = $file_base . '-' . $handle . '.json'; 925 924 if ( $path && file_exists( $path . '/' . $handle_filename ) ) { 926 return file_get_contents( $path . '/' . $handle_filename);925 return load_script_translations( $path . '/' . $handle_filename, $handle, $domain ); 927 926 } 928 927 … … 978 977 // If the source is not from WP. 979 978 if ( false === $relative ) { 980 return false;979 return load_script_translations( false, $handle, $domain ); 981 980 } 982 981 … … 988 987 $md5_filename = $file_base . '-' . md5( $relative ) . '.json'; 989 988 if ( $path && file_exists( $path . '/' . $md5_filename ) ) { 990 return file_get_contents( $path . '/' . $md5_filename);989 return load_script_translations( $path . '/' . $md5_filename, $handle, $domain ); 991 990 } 992 991 if ( file_exists( $languages_path . '/' . $md5_filename ) ) { 993 return file_get_contents( $languages_path . '/' . $md5_filename ); 994 } 995 996 return false; 992 return load_script_translations( $languages_path . '/' . $md5_filename, $handle, $domain ); 993 } 994 995 return load_script_translations( false, $handle, $domain ); 996 } 997 998 /** 999 * Loads the translation data for the given script handle and text domain. 1000 * 1001 * @since 5.0.2 1002 * 1003 * @param string|false $file Path to the translation file to load. False if there isn't one. 1004 * @param string $handle Name of the script to register a translation domain to. 1005 * @param string $domain The text domain. 1006 * @return string|false The JSON-encoded translated strings for the given script handle and text domain. False if there are none. 1007 */ 1008 function load_script_translations( $file, $handle, $domain ) { 1009 /** 1010 * Pre-filters script translations for the given file, script handle and text domain. 1011 * 1012 * Returning a non-null value allows to override the default logic, effectively short-circuiting the function. 1013 * 1014 * @since 5.0.2 1015 * 1016 * @param string|false $translations JSON-encoded translation data. Default null. 1017 * @param string|false $file Path to the translation file to load. False if there isn't one. 1018 * @param string $handle Name of the script to register a translation domain to. 1019 * @param string $domain The text domain. 1020 */ 1021 $translations = apply_filters( 'pre_load_script_translations', null, $file, $handle, $domain ); 1022 1023 if ( null !== $translations ) { 1024 return $translations; 1025 } 1026 1027 /** 1028 * Filters the file path for loading script translations for the given script handle and text domain. 1029 * 1030 * @since 5.0.2 1031 * 1032 * @param string|false $file Path to the translation file to load. False if there isn't one. 1033 * @param string $handle Name of the script to register a translation domain to. 1034 * @param string $domain The text domain. 1035 */ 1036 $file = apply_filters( 'load_script_translation_file', $file, $handle, $domain ); 1037 1038 if ( ! $file || ! is_readable( $file ) ) { 1039 return false; 1040 } 1041 1042 $translations = file_get_contents( $file ); 1043 1044 /** 1045 * Filters script translations for the given file, script handle and text domain. 1046 * 1047 * @since 5.0.2 1048 * 1049 * @param string $translations JSON-encoded translation data. 1050 * @param string $file Path to the translation file that was loaded. 1051 * @param string $handle Name of the script to register a translation domain to. 1052 * @param string $domain The text domain. 1053 */ 1054 return apply_filters( 'load_script_translations', $translations, $file, $handle, $domain ); 997 1055 } 998 1056
Note: See TracChangeset
for help on using the changeset viewer.