Changeset 59157 for trunk/src/wp-includes/l10n.php
- Timestamp:
- 10/02/2024 01:42:11 PM (2 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/l10n.php
r59127 r59157 984 984 * @since 1.5.0 985 985 * @since 4.6.0 The function now tries to load the .mo file from the languages directory first. 986 * @since 6.7.0 Translations are no longer immediately loaded, but handed off to the just-in-time loading mechanism. 986 987 * 987 988 * @param string $domain Unique identifier for retrieving translated strings … … 998 999 if ( ! is_string( $domain ) ) { 999 1000 return false; 1000 }1001 1002 if ( ! doing_action( 'after_setup_theme' ) && ! did_action( 'after_setup_theme' ) ) {1003 _doing_it_wrong(1004 __FUNCTION__,1005 sprintf(1006 /* translators: 1: The text domain. 2: 'after_setup_theme'. */1007 __( 'Attempted to load translations for the %1$s domain too early. Translations should be loaded after the %2$s action has fired, to ensure that the current user is already set up.' ),1008 '<code>' . $domain . '</code>',1009 '<code>after_setup_theme</code>'1010 ),1011 '6.7.0'1012 );1013 }1014 1015 /**1016 * Filters a plugin's locale.1017 *1018 * @since 3.0.01019 *1020 * @param string $locale The plugin's current locale.1021 * @param string $domain Text domain. Unique identifier for retrieving translated strings.1022 */1023 $locale = apply_filters( 'plugin_locale', determine_locale(), $domain );1024 1025 $mofile = $domain . '-' . $locale . '.mo';1026 1027 // Try to load from the languages directory first.1028 if ( load_textdomain( $domain, WP_LANG_DIR . '/plugins/' . $mofile, $locale ) ) {1029 return true;1030 1001 } 1031 1002 … … 1041 1012 $wp_textdomain_registry->set_custom_path( $domain, $path ); 1042 1013 1043 return load_textdomain( $domain, $path . '/' . $mofile, $locale );1014 return true; 1044 1015 } 1045 1016 … … 1049 1020 * @since 3.0.0 1050 1021 * @since 4.6.0 The function now tries to load the .mo file from the languages directory first. 1022 * @since 6.7.0 Translations are no longer immediately loaded, but handed off to the just-in-time loading mechanism. 1051 1023 * 1052 1024 * @global WP_Textdomain_Registry $wp_textdomain_registry WordPress Textdomain Registry. … … 1065 1037 } 1066 1038 1067 if ( ! doing_action( 'after_setup_theme' ) && ! did_action( 'after_setup_theme' ) ) {1068 _doing_it_wrong(1069 __FUNCTION__,1070 sprintf(1071 /* translators: 1: The text domain. 2: 'after_setup_theme'. */1072 __( 'Attempted to load translations for the %1$s domain too early. Translations should be loaded after the %2$s action has fired, to ensure that the current user is already set up.' ),1073 '<code>' . $domain . '</code>',1074 '<code>after_setup_theme</code>'1075 ),1076 '6.7.0'1077 );1078 }1079 1080 /** This filter is documented in wp-includes/l10n.php */1081 $locale = apply_filters( 'plugin_locale', determine_locale(), $domain );1082 1083 $mofile = $domain . '-' . $locale . '.mo';1084 1085 // Try to load from the languages directory first.1086 if ( load_textdomain( $domain, WP_LANG_DIR . '/plugins/' . $mofile, $locale ) ) {1087 return true;1088 }1089 1090 1039 $path = WPMU_PLUGIN_DIR . '/' . ltrim( $mu_plugin_rel_path, '/' ); 1091 1040 1092 1041 $wp_textdomain_registry->set_custom_path( $domain, $path ); 1093 1042 1094 return load_textdomain( $domain, $path . '/' . $mofile, $locale );1043 return true; 1095 1044 } 1096 1045 … … 1105 1054 * @since 1.5.0 1106 1055 * @since 4.6.0 The function now tries to load the .mo file from the languages directory first. 1056 * @since 6.7.0 Translations are no longer immediately loaded, but handed off to the just-in-time loading mechanism. 1107 1057 * 1108 1058 * @global WP_Textdomain_Registry $wp_textdomain_registry WordPress Textdomain Registry. … … 1121 1071 } 1122 1072 1123 if ( ! doing_action( 'after_setup_theme' ) && ! did_action( 'after_setup_theme' ) ) {1124 _doing_it_wrong(1125 __FUNCTION__,1126 sprintf(1127 /* translators: 1: The text domain. 2: 'after_setup_theme'. */1128 __( 'Attempted to load translations for the %1$s domain too early. Translations should be loaded after the %2$s action has fired, to ensure that the current user is already set up.' ),1129 '<code>' . $domain . '</code>',1130 '<code>after_setup_theme</code>'1131 ),1132 '6.7.0'1133 );1134 }1135 1136 /**1137 * Filters a theme's locale.1138 *1139 * @since 3.0.01140 *1141 * @param string $locale The theme's current locale.1142 * @param string $domain Text domain. Unique identifier for retrieving translated strings.1143 */1144 $locale = apply_filters( 'theme_locale', determine_locale(), $domain );1145 1146 $mofile = $domain . '-' . $locale . '.mo';1147 1148 // Try to load from the languages directory first.1149 if ( load_textdomain( $domain, WP_LANG_DIR . '/themes/' . $mofile, $locale ) ) {1150 return true;1151 }1152 1153 1073 if ( ! $path ) { 1154 1074 $path = get_template_directory(); … … 1157 1077 $wp_textdomain_registry->set_custom_path( $domain, $path ); 1158 1078 1159 return load_textdomain( $domain, $path . '/' . $locale . '.mo', $locale );1079 return true; 1160 1080 } 1161 1081 … … 1426 1346 __FUNCTION__, 1427 1347 sprintf( 1428 /* translators: %s: The text domain. */ 1429 __( 'Translation loading for the %s domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early.' ), 1430 '<code>' . $domain . '</code>' 1348 /* translators: 1: The text domain. 2: 'init'. */ 1349 __( 'Translation loading for the %1$s domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the %2$s action or later.' ), 1350 '<code>' . $domain . '</code>', 1351 '<code>init</code>' 1431 1352 ), 1432 1353 '6.7.0'
Note: See TracChangeset
for help on using the changeset viewer.