Changeset 49566
- Timestamp:
- 11/12/2020 02:41:19 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 5 deleted
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-locale-switcher.php
r49236 r49566 197 197 198 198 foreach ( $domains as $domain ) { 199 // The default text domain is handled by `load_default_textdomain()`.200 199 if ( 'default' === $domain ) { 201 200 continue; 202 201 } 203 202 204 unload_textdomain( $domain , true);203 unload_textdomain( $domain ); 205 204 get_translations_for_domain( $domain ); 206 205 } … … 220 219 */ 221 220 private function change_locale( $locale ) { 222 global $wp_locale; 221 // Reset translation availability information. 222 _get_path_to_translation( null, true ); 223 223 224 224 $this->load_translations( $locale ); 225 225 226 $ wp_locale= new WP_Locale();226 $GLOBALS['wp_locale'] = new WP_Locale(); 227 227 228 228 /** -
trunk/src/wp-includes/deprecated.php
r49236 r49566 4135 4135 return is_string( $value ) ? addslashes( $value ) : $value; 4136 4136 } 4137 4138 /**4139 * Gets the path to a translation file for loading a textdomain just in time.4140 *4141 * Caches the retrieved results internally.4142 *4143 * @since 4.7.04144 * @deprecated 5.6.04145 * @access private4146 *4147 * @see _load_textdomain_just_in_time()4148 *4149 * @param string $domain Text domain. Unique identifier for retrieving translated strings.4150 * @param bool $reset Whether to reset the internal cache. Used by the switch to locale functionality.4151 * @return string|false The path to the translation file or false if no translation file was found.4152 */4153 function _get_path_to_translation( $domain, $reset = false ) {4154 _deprecated_function( __FUNCTION__, '5.6.0', 'WP_Textdomain_Registry' );4155 4156 static $available_translations = array();4157 4158 if ( true === $reset ) {4159 $available_translations = array();4160 }4161 4162 if ( ! isset( $available_translations[ $domain ] ) ) {4163 $available_translations[ $domain ] = _get_path_to_translation_from_lang_dir( $domain );4164 }4165 4166 return $available_translations[ $domain ];4167 }4168 4169 /**4170 * Gets the path to a translation file in the languages directory for the current locale.4171 *4172 * Holds a cached list of available .mo files to improve performance.4173 *4174 * @since 4.7.04175 * @deprecated 5.6.04176 * @access private4177 *4178 * @see _get_path_to_translation()4179 *4180 * @param string $domain Text domain. Unique identifier for retrieving translated strings.4181 * @return string|false The path to the translation file or false if no translation file was found.4182 */4183 function _get_path_to_translation_from_lang_dir( $domain ) {4184 _deprecated_function( __FUNCTION__, '5.6.0', 'WP_Textdomain_Registry' );4185 4186 static $cached_mofiles = null;4187 4188 if ( null === $cached_mofiles ) {4189 $cached_mofiles = array();4190 4191 $locations = array(4192 WP_LANG_DIR . '/plugins',4193 WP_LANG_DIR . '/themes',4194 );4195 4196 foreach ( $locations as $location ) {4197 $mofiles = glob( $location . '/*.mo' );4198 if ( $mofiles ) {4199 $cached_mofiles = array_merge( $cached_mofiles, $mofiles );4200 }4201 }4202 }4203 4204 $locale = determine_locale();4205 $mofile = "{$domain}-{$locale}.mo";4206 4207 $path = WP_LANG_DIR . '/plugins/' . $mofile;4208 if ( in_array( $path, $cached_mofiles, true ) ) {4209 return $path;4210 }4211 4212 $path = WP_LANG_DIR . '/themes/' . $mofile;4213 if ( in_array( $path, $cached_mofiles, true ) ) {4214 return $path;4215 }4216 4217 return false;4218 } -
trunk/src/wp-includes/l10n.php
r49236 r49566 690 690 * @since 1.5.0 691 691 * 692 * @global MO[] $l10n An array of all currently loaded text domains. 693 * @global MO[] $l10n_unloaded An array of all text domains that have been unloaded again. 694 * @global WP_Textdomain_Registry $wp_textdomain_registry WordPress Textdomain Registry. 692 * @global MO[] $l10n An array of all currently loaded text domains. 693 * @global MO[] $l10n_unloaded An array of all text domains that have been unloaded again. 695 694 * 696 695 * @param string $domain Text domain. Unique identifier for retrieving translated strings. … … 699 698 */ 700 699 function load_textdomain( $domain, $mofile ) { 701 global $l10n, $l10n_unloaded , $wp_textdomain_registry;700 global $l10n, $l10n_unloaded; 702 701 703 702 $l10n_unloaded = (array) $l10n_unloaded; … … 757 756 $l10n[ $domain ] = &$mo; 758 757 759 /** @var WP_Textdomain_Registry $wp_textdomain_registry */760 $wp_textdomain_registry->set( $domain, dirname( $mofile ) );761 762 758 return true; 763 759 } … … 767 763 * 768 764 * @since 3.0.0 769 * @since 5.6.0 Added the `$reloadable` parameter.770 765 * 771 766 * @global MO[] $l10n An array of all currently loaded text domains. 772 767 * @global MO[] $l10n_unloaded An array of all text domains that have been unloaded again. 773 768 * 774 * @param string $domain Text domain. Unique identifier for retrieving translated strings. 775 * @param bool $reloadable Whether the text domain can be loaded just-in-time again. 769 * @param string $domain Text domain. Unique identifier for retrieving translated strings. 776 770 * @return bool Whether textdomain was unloaded. 777 771 */ 778 function unload_textdomain( $domain , $reloadable = false) {772 function unload_textdomain( $domain ) { 779 773 global $l10n, $l10n_unloaded; 780 774 … … 785 779 * 786 780 * @since 3.0.0 787 * @since 5.6.0 Added the `$reloadable` parameter. 788 * 789 * @param bool $override Whether to override the text domain unloading. Default false. 790 * @param string $domain Text domain. Unique identifier for retrieving translated strings. 791 * @param bool $reloadable Whether the text domain can be loaded just-in-time again. 792 */ 793 $plugin_override = apply_filters( 'override_unload_textdomain', false, $domain, $reloadable ); 781 * 782 * @param bool $override Whether to override the text domain unloading. Default false. 783 * @param string $domain Text domain. Unique identifier for retrieving translated strings. 784 */ 785 $plugin_override = apply_filters( 'override_unload_textdomain', false, $domain ); 794 786 795 787 if ( $plugin_override ) { 796 if ( ! $reloadable ) { 797 $l10n_unloaded[ $domain ] = true; 798 } 788 $l10n_unloaded[ $domain ] = true; 799 789 800 790 return true; … … 805 795 * 806 796 * @since 3.0.0 807 * @since 5.6.0 Added the `$reloadable` parameter. 808 * 809 * @param string $domain Text domain. Unique identifier for retrieving translated strings. 810 * @param bool $reloadable Whether the text domain can be loaded just-in-time again. 811 */ 812 do_action( 'unload_textdomain', $domain, $reloadable ); 797 * 798 * @param string $domain Text domain. Unique identifier for retrieving translated strings. 799 */ 800 do_action( 'unload_textdomain', $domain ); 813 801 814 802 if ( isset( $l10n[ $domain ] ) ) { 815 803 unset( $l10n[ $domain ] ); 816 804 817 if ( ! $reloadable ) { 818 $l10n_unloaded[ $domain ] = true; 819 } 805 $l10n_unloaded[ $domain ] = true; 820 806 821 807 return true; … … 882 868 */ 883 869 function load_plugin_textdomain( $domain, $deprecated = false, $plugin_rel_path = false ) { 884 global $wp_textdomain_registry;885 886 870 /** 887 871 * Filters a plugin's locale. … … 910 894 } 911 895 912 /* @var WP_Textdomain_Registry $wp_textdomain_registry */913 $wp_textdomain_registry->set( $domain, $path );914 915 896 return load_textdomain( $domain, $path . '/' . $mofile ); 916 897 } … … 921 902 * @since 3.0.0 922 903 * @since 4.6.0 The function now tries to load the .mo file from the languages directory first. 923 *924 * @global WP_Textdomain_Registry $wp_textdomain_registry WordPress Textdomain Registry.925 904 * 926 905 * @param string $domain Text domain. Unique identifier for retrieving translated strings. … … 930 909 */ 931 910 function load_muplugin_textdomain( $domain, $mu_plugin_rel_path = '' ) { 932 global $wp_textdomain_registry;933 934 911 /** This filter is documented in wp-includes/l10n.php */ 935 912 $locale = apply_filters( 'plugin_locale', determine_locale(), $domain ); … … 944 921 $path = WPMU_PLUGIN_DIR . '/' . ltrim( $mu_plugin_rel_path, '/' ); 945 922 946 /* @var WP_Textdomain_Registry $wp_textdomain_registry */947 $wp_textdomain_registry->set( $domain, $path );948 949 923 return load_textdomain( $domain, $path . '/' . $mofile ); 950 924 } … … 960 934 * @since 1.5.0 961 935 * @since 4.6.0 The function now tries to load the .mo file from the languages directory first. 962 *963 * @global WP_Textdomain_Registry $wp_textdomain_registry WordPress Textdomain Registry.964 936 * 965 937 * @param string $domain Text domain. Unique identifier for retrieving translated strings. … … 969 941 */ 970 942 function load_theme_textdomain( $domain, $path = false ) { 971 global $wp_textdomain_registry;972 973 943 /** 974 944 * Filters a theme's locale. … … 991 961 $path = get_template_directory(); 992 962 } 993 994 /* @var WP_Textdomain_Registry $wp_textdomain_registry */995 $wp_textdomain_registry->set( $domain, $path );996 963 997 964 return load_textdomain( $domain, $path . '/' . $locale . '.mo' ); … … 1224 1191 * @access private 1225 1192 * 1226 * @ global MO[] $l10n_unloaded An array of all text domains that have been unloaded again.1227 * @global WP_Textdomain_Registry $wp_textdomain_registry WordPress Textdomain Registry.1193 * @see get_translations_for_domain() 1194 * @global MO[] $l10n_unloaded An array of all text domains that have been unloaded again. 1228 1195 * 1229 1196 * @param string $domain Text domain. Unique identifier for retrieving translated strings. … … 1231 1198 */ 1232 1199 function _load_textdomain_just_in_time( $domain ) { 1233 global $l10n_unloaded , $wp_textdomain_registry;1200 global $l10n_unloaded; 1234 1201 1235 1202 $l10n_unloaded = (array) $l10n_unloaded; … … 1240 1207 } 1241 1208 1242 /** @var WP_Textdomain_Registry $wp_textdomain_registry */ 1243 $path = $wp_textdomain_registry->get( $domain ); 1244 if ( ! $path ) { 1209 $translation_path = _get_path_to_translation( $domain ); 1210 if ( false === $translation_path ) { 1245 1211 return false; 1246 1212 } 1247 1213 1214 return load_textdomain( $domain, $translation_path ); 1215 } 1216 1217 /** 1218 * Gets the path to a translation file for loading a textdomain just in time. 1219 * 1220 * Caches the retrieved results internally. 1221 * 1222 * @since 4.7.0 1223 * @access private 1224 * 1225 * @see _load_textdomain_just_in_time() 1226 * 1227 * @param string $domain Text domain. Unique identifier for retrieving translated strings. 1228 * @param bool $reset Whether to reset the internal cache. Used by the switch to locale functionality. 1229 * @return string|false The path to the translation file or false if no translation file was found. 1230 */ 1231 function _get_path_to_translation( $domain, $reset = false ) { 1232 static $available_translations = array(); 1233 1234 if ( true === $reset ) { 1235 $available_translations = array(); 1236 } 1237 1238 if ( ! isset( $available_translations[ $domain ] ) ) { 1239 $available_translations[ $domain ] = _get_path_to_translation_from_lang_dir( $domain ); 1240 } 1241 1242 return $available_translations[ $domain ]; 1243 } 1244 1245 /** 1246 * Gets the path to a translation file in the languages directory for the current locale. 1247 * 1248 * Holds a cached list of available .mo files to improve performance. 1249 * 1250 * @since 4.7.0 1251 * @access private 1252 * 1253 * @see _get_path_to_translation() 1254 * 1255 * @param string $domain Text domain. Unique identifier for retrieving translated strings. 1256 * @return string|false The path to the translation file or false if no translation file was found. 1257 */ 1258 function _get_path_to_translation_from_lang_dir( $domain ) { 1259 static $cached_mofiles = null; 1260 1261 if ( null === $cached_mofiles ) { 1262 $cached_mofiles = array(); 1263 1264 $locations = array( 1265 WP_LANG_DIR . '/plugins', 1266 WP_LANG_DIR . '/themes', 1267 ); 1268 1269 foreach ( $locations as $location ) { 1270 $mofiles = glob( $location . '/*.mo' ); 1271 if ( $mofiles ) { 1272 $cached_mofiles = array_merge( $cached_mofiles, $mofiles ); 1273 } 1274 } 1275 } 1276 1248 1277 $locale = determine_locale(); 1249 1250 // Themes with their language directory outside of WP_LANG_DIR have a different file name. 1251 $template_directory = trailingslashit( get_template_directory() ); 1252 $stylesheet_directory = trailingslashit( get_stylesheet_directory() ); 1253 if ( 0 === strpos( $path, $template_directory ) || 0 === strpos( $path, $stylesheet_directory ) ) { 1254 $mofile = "{$path}{$locale}.mo"; 1255 } else { 1256 $mofile = "{$path}{$domain}-{$locale}.mo"; 1257 } 1258 1259 return load_textdomain( $domain, $mofile ); 1278 $mofile = "{$domain}-{$locale}.mo"; 1279 1280 $path = WP_LANG_DIR . '/plugins/' . $mofile; 1281 if ( in_array( $path, $cached_mofiles, true ) ) { 1282 return $path; 1283 } 1284 1285 $path = WP_LANG_DIR . '/themes/' . $mofile; 1286 if ( in_array( $path, $cached_mofiles, true ) ) { 1287 return $path; 1288 } 1289 1290 return false; 1260 1291 } 1261 1292 … … 1267 1298 * @since 2.8.0 1268 1299 * 1269 * @global MO[] $l10n An array of all currently loaded text domains.1300 * @global MO[] $l10n 1270 1301 * 1271 1302 * @param string $domain Text domain. Unique identifier for retrieving translated strings. … … 1291 1322 * @since 3.0.0 1292 1323 * 1293 * @global MO[] $l10n An array of all currently loaded text domains.1324 * @global MO[] $l10n 1294 1325 * 1295 1326 * @param string $domain Text domain. Unique identifier for retrieving translated strings. -
trunk/src/wp-settings.php
r49236 r49566 153 153 // Load the L10n library. 154 154 require_once ABSPATH . WPINC . '/l10n.php'; 155 require_once ABSPATH . WPINC . '/class-wp-textdomain-registry.php';156 155 require_once ABSPATH . WPINC . '/class-wp-locale.php'; 157 156 require_once ABSPATH . WPINC . '/class-wp-locale-switcher.php'; … … 303 302 $GLOBALS['wp_embed'] = new WP_Embed(); 304 303 305 /**306 * WordPress Textdomain Registry object.307 *308 * Used to support just-in-time translations for manually loaded textdomains.309 *310 * @since 5.6.0311 *312 * @global WP_Locale_Switcher $wp_locale_switcher WordPress Textdomain Registry.313 */314 $GLOBALS['wp_textdomain_registry'] = new WP_Textdomain_Registry();315 316 304 // Load multisite-specific files. 317 305 if ( is_multisite() ) { -
trunk/tests/phpunit/data/languages/plugins/internationalized-plugin-de_DE.po
r49236 r49566 3 3 "Project-Id-Version: \n" 4 4 "POT-Creation-Date: 2015-12-31 16:31+0100\n" 5 "PO-Revision-Date: 20 20-10-20 17:11+0200\n"5 "PO-Revision-Date: 2016-10-26 00:02+0200\n" 6 6 "Language: de_DE\n" 7 7 "MIME-Version: 1.0\n" 8 8 "Content-Type: text/plain; charset=UTF-8\n" 9 9 "Content-Transfer-Encoding: 8bit\n" 10 "X-Generator: Poedit 2.4.1\n"10 "X-Generator: Poedit 1.8.10\n" 11 11 "X-Poedit-Basepath: .\n" 12 12 "Plural-Forms: nplurals=2; plural=(n != 1);\n" … … 15 15 "esc_html_x:1,2c\n" 16 16 "X-Textdomain-Support: yes\n" 17 "Language-Team: \n"18 "Last-Translator: \n"19 17 "X-Poedit-SearchPath-0: .\n" 20 18 -
trunk/tests/phpunit/data/languages/themes/internationalized-theme-de_DE.po
r49236 r49566 3 3 "Project-Id-Version: \n" 4 4 "POT-Creation-Date: 2015-12-31 16:38+0100\n" 5 "PO-Revision-Date: 20 20-10-20 17:09+0200\n"5 "PO-Revision-Date: 2016-10-26 00:02+0200\n" 6 6 "Language: de_DE\n" 7 7 "MIME-Version: 1.0\n" 8 8 "Content-Type: text/plain; charset=UTF-8\n" 9 9 "Content-Transfer-Encoding: 8bit\n" 10 "X-Generator: Poedit 2.4.1\n"10 "X-Generator: Poedit 1.8.10\n" 11 11 "X-Poedit-Basepath: .\n" 12 12 "Plural-Forms: nplurals=2; plural=(n != 1);\n" … … 15 15 "esc_html_x:1,2c\n" 16 16 "X-Textdomain-Support: yes\n" 17 "Last-Translator: \n"18 "Language-Team: \n"19 17 "X-Poedit-SearchPath-0: .\n" 20 18 -
trunk/tests/phpunit/data/plugins/hello.php
r49236 r49566 5 5 Description: This is not just a plugin, it symbolizes the hope and enthusiasm of an entire generation summed up in two words sung most famously by Louis Armstrong: Hello, Dolly. When activated you will randomly see a lyric from <cite>Hello, Dolly</cite> in the upper right of your admin screen on every page. 6 6 Author: Matt Mullenweg 7 Version: 1. 7.27 Version: 1.5.1 8 8 Author URI: http://ma.tt/ 9 9 Text Domain: hello-dolly 10 10 11 11 */ 12 13 // Test for 14 ?> -
trunk/tests/phpunit/includes/bootstrap.php
r49535 r49566 38 38 require_once __DIR__ . '/functions.php'; 39 39 40 if ( defined( 'WP_RUN_CORE_TESTS' ) && WP_RUN_CORE_TESTS && ! is_dir( ABSPATH ) ) {41 echo "Error: The /build/ directory is missing! Please run `npm run build` prior to running PHPUnit.\n";42 exit( 1 );43 }44 45 40 $phpunit_version = tests_get_phpunit_version(); 46 41 … … 54 49 } 55 50 56 $required_extensions = array( 57 'gd', 58 ); 59 $missing_extensions = array(); 60 61 foreach ( $required_extensions as $extension ) { 62 if ( ! extension_loaded( $extension ) ) { 63 $missing_extensions[] = $extension; 64 } 65 } 66 67 if ( $missing_extensions ) { 68 printf( 69 "Error: The following required PHP extensions are missing from the testing environment: %s.\n", 70 implode( ', ', $missing_extensions ) 71 ); 72 echo "Please make sure they are installed and enabled.\n", 51 if ( defined( 'WP_RUN_CORE_TESTS' ) && WP_RUN_CORE_TESTS && ! is_dir( ABSPATH ) ) { 52 echo "Error: The /build/ directory is missing! Please run `npm run build` prior to running PHPUnit.\n"; 73 53 exit( 1 ); 74 54 } … … 80 60 'WP_PHP_BINARY', 81 61 ); 82 $missing_constants = array();83 62 84 63 foreach ( $required_constants as $constant ) { 85 64 if ( ! defined( $constant ) ) { 86 $missing_constants[] = $constant; 87 } 88 } 89 90 if ( $missing_constants ) { 91 printf( 92 "Error: The following required constants are not defined: %s.\n", 93 implode( ', ', $missing_constants ) 94 ); 95 echo "Please check out `wp-tests-config-sample.php` for an example.\n", 96 exit( 1 ); 65 printf( 66 "Error: The required %s constant is not defined. Check out `wp-tests-config-sample.php` for an example.\n", 67 $constant 68 ); 69 exit( 1 ); 70 } 97 71 } 98 72 … … 103 77 define( 'DIR_TESTROOT', realpath( dirname( __DIR__ ) ) ); 104 78 105 define( 'WP_LANG_DIR', realpath( DIR_TESTDATA . '/languages' ) ); 106 107 if ( defined( 'WP_RUN_CORE_TESTS' ) && WP_RUN_CORE_TESTS ) { 108 define( 'WP_PLUGIN_DIR', realpath( DIR_TESTDATA . '/plugins' ) ); 109 } 79 define( 'WP_LANG_DIR', DIR_TESTDATA . '/languages' ); 110 80 111 81 if ( ! defined( 'WP_TESTS_FORCE_KNOWN_BUGS' ) ) { … … 171 141 // Use the Spy REST Server instead of default. 172 142 tests_add_filter( 'wp_rest_server_class', '_wp_rest_server_class_filter' ); 173 // Prevent updating translations asynchronously.174 tests_add_filter( 'async_update_translation', '__return_false' );175 // Disable background updates.176 tests_add_filter( 'automatic_updater_disabled', '__return_true' );177 143 178 144 // Preset WordPress options defined in bootstrap file. -
trunk/tests/phpunit/tests/admin/includesPlugin.php
r49236 r49566 15 15 'Author' => '<a href="http://ma.tt/">Matt Mullenweg</a>', 16 16 'AuthorURI' => 'http://ma.tt/', 17 'Version' => '1. 7.2',17 'Version' => '1.5.1', 18 18 'TextDomain' => 'hello-dolly', 19 19 'DomainPath' => '', -
trunk/tests/phpunit/tests/l10n/loadTextdomain.php
r49236 r49566 25 25 add_filter( 'plugin_locale', array( $this, 'store_locale' ) ); 26 26 add_filter( 'theme_locale', array( $this, 'store_locale' ) ); 27 28 /** @var WP_Textdomain_Registry $wp_textdomain_registry */29 global $wp_textdomain_registry;30 31 $wp_textdomain_registry->reset();32 27 } 33 28 … … 36 31 remove_filter( 'theme_locale', array( $this, 'store_locale' ) ); 37 32 38 /** @var WP_Textdomain_Registry $wp_textdomain_registry */39 global $wp_textdomain_registry;40 41 $wp_textdomain_registry->reset();42 43 33 parent::tearDown(); 44 34 } … … 127 117 * @ticket 21319 128 118 */ 129 publicfunction test_is_textdomain_is_not_loaded_after_gettext_call_with_no_translations() {119 function test_is_textdomain_is_not_loaded_after_gettext_call_with_no_translations() { 130 120 $this->assertFalse( is_textdomain_loaded( 'wp-tests-domain' ) ); 131 121 __( 'just some string', 'wp-tests-domain' ); … … 133 123 } 134 124 135 publicfunction test_override_load_textdomain_noop() {125 function test_override_load_textdomain_noop() { 136 126 add_filter( 'override_load_textdomain', '__return_true' ); 137 127 $load_textdomain = load_textdomain( 'wp-tests-domain', DIR_TESTDATA . '/non-existent-file' ); … … 142 132 } 143 133 144 publicfunction test_override_load_textdomain_non_existent_mofile() {134 function test_override_load_textdomain_non_existent_mofile() { 145 135 add_filter( 'override_load_textdomain', array( $this, '_override_load_textdomain_filter' ), 10, 3 ); 146 136 $load_textdomain = load_textdomain( 'wp-tests-domain', WP_LANG_DIR . '/non-existent-file.mo' ); … … 156 146 } 157 147 158 publicfunction test_override_load_textdomain_custom_mofile() {148 function test_override_load_textdomain_custom_mofile() { 159 149 add_filter( 'override_load_textdomain', array( $this, '_override_load_textdomain_filter' ), 10, 3 ); 160 150 $load_textdomain = load_textdomain( 'wp-tests-domain', WP_LANG_DIR . '/plugins/internationalized-plugin-de_DE.mo' ); … … 176 166 * @return bool 177 167 */ 178 publicfunction _override_load_textdomain_filter( $override, $domain, $file ) {168 function _override_load_textdomain_filter( $override, $domain, $file ) { 179 169 global $l10n; 180 170 -
trunk/tests/phpunit/tests/l10n/loadTextdomainJustInTime.php
r49236 r49566 33 33 add_filter( 'template_root', array( $this, 'filter_theme_root' ) ); 34 34 wp_clean_themes_cache(); 35 unset( $GLOBALS['wp_themes'], $GLOBALS['l10n'], $GLOBALS['l10n_unloaded'] ); 36 37 /** @var WP_Textdomain_Registry $wp_textdomain_registry */ 38 global $wp_textdomain_registry; 39 40 $wp_textdomain_registry->reset(); 35 unset( $GLOBALS['wp_themes'] ); 36 unset( $GLOBALS['l10n'] ); 37 unset( $GLOBALS['l10n_unloaded'] ); 38 _get_path_to_translation( null, true ); 41 39 } 42 40 … … 47 45 remove_filter( 'template_root', array( $this, 'filter_theme_root' ) ); 48 46 wp_clean_themes_cache(); 49 unset( $GLOBALS['wp_themes'], $GLOBALS['l10n'], $GLOBALS['l10n_unloaded'] ); 50 51 /** @var WP_Textdomain_Registry $wp_textdomain_registry */ 52 global $wp_textdomain_registry; 53 54 $wp_textdomain_registry->reset(); 47 unset( $GLOBALS['wp_themes'] ); 48 unset( $GLOBALS['l10n'] ); 49 unset( $GLOBALS['l10n_unloaded'] ); 50 _get_path_to_translation( null, true ); 55 51 56 52 parent::tearDown(); … … 175 171 /** 176 172 * @ticket 37997 177 * @ticket 39210178 173 */ 179 174 public function test_plugin_translation_after_switching_locale_twice() { … … 189 184 190 185 $this->assertSame( 'Das ist ein Dummy Plugin', $expected_de_de ); 191 $this->assertSame( ' Este es un plugin dummy', $expected_es_es );186 $this->assertSame( 'This is a dummy plugin', $expected_es_es ); 192 187 } 193 188 -
trunk/tests/phpunit/tests/l10n/localeSwitcher.php
r49236 r49566 23 23 $this->previous_locale = ''; 24 24 25 unset( $GLOBALS['l10n'], $GLOBALS['l10n_unloaded'] ); 26 27 /** @var WP_Textdomain_Registry $wp_textdomain_registry */ 28 global $wp_textdomain_registry; 29 30 $wp_textdomain_registry->reset(); 25 unset( $GLOBALS['l10n'] ); 26 unset( $GLOBALS['l10n_unloaded'] ); 27 _get_path_to_translation( null, true ); 31 28 } 32 29 33 30 public function tearDown() { 34 unset( $GLOBALS['l10n'], $GLOBALS['l10n_unloaded'] ); 35 36 /** @var WP_Textdomain_Registry $wp_textdomain_registry */ 37 global $wp_textdomain_registry; 38 39 $wp_textdomain_registry->reset(); 31 unset( $GLOBALS['l10n'] ); 32 unset( $GLOBALS['l10n_unloaded'] ); 33 _get_path_to_translation( null, true ); 40 34 41 35 parent::tearDown(); … … 395 389 } 396 390 397 /**398 * @ticket 39210399 */400 public function test_switch_reloads_plugin_translations_outside_wp_lang_dir() {401 global $wp_locale_switcher, $wp_textdomain_registry;402 403 $locale_switcher = clone $wp_locale_switcher;404 405 $wp_locale_switcher = new WP_Locale_Switcher();406 $wp_locale_switcher->init();407 408 require_once DIR_TESTDATA . '/plugins/custom-internationalized-plugin/custom-internationalized-plugin.php';409 410 $this->assertSame( WP_PLUGIN_DIR . '/custom-internationalized-plugin/languages/', $wp_textdomain_registry->get( 'custom-internationalized-plugin' ) );411 412 $expected = custom_i18n_plugin_test();413 $this->assertSame( 'This is a dummy plugin', $expected );414 415 switch_to_locale( 'es_ES' );416 switch_to_locale( 'de_DE' );417 418 $expected = custom_i18n_plugin_test();419 $this->assertSame( 'Das ist ein Dummy Plugin', $expected );420 421 restore_previous_locale();422 423 $expected = custom_i18n_plugin_test();424 $this->assertSame( 'Este es un plugin dummy', $expected );425 426 restore_current_locale();427 428 $wp_locale_switcher = $locale_switcher;429 }430 431 /**432 * @ticket 39210433 */434 public function test_switch_reloads_theme_translations_outside_wp_lang_dir() {435 global $wp_locale_switcher, $wp_textdomain_registry;436 437 $locale_switcher = clone $wp_locale_switcher;438 439 $wp_locale_switcher = new WP_Locale_Switcher();440 $wp_locale_switcher->init();441 442 switch_theme( 'custom-internationalized-theme' );443 444 require_once get_stylesheet_directory() . '/functions.php';445 446 $this->assertSame( get_template_directory() . '/languages/', $wp_textdomain_registry->get( 'custom-internationalized-theme' ) );447 448 $expected = custom_i18n_theme_test();449 450 $this->assertSame( 'This is a dummy theme', $expected );451 452 switch_to_locale( 'es_ES' );453 switch_to_locale( 'de_DE' );454 455 $expected = custom_i18n_theme_test();456 $this->assertSame( 'Das ist ein Dummy Theme', $expected );457 458 restore_previous_locale();459 460 $expected = custom_i18n_theme_test();461 $this->assertSame( 'Este es un tema dummy', $expected );462 463 restore_current_locale();464 465 $wp_locale_switcher = $locale_switcher;466 }467 468 391 public function filter_locale() { 469 392 return 'es_ES'; -
trunk/tests/phpunit/tests/theme/themeDir.php
r49236 r49566 163 163 'Theme with Spaces in the Directory', 164 164 'Internationalized Theme', 165 'Custom Internationalized Theme',166 165 'camelCase', 167 166 'REST Theme',
Note: See TracChangeset
for help on using the changeset viewer.