I18N: Revert [49236] for now to investigate alternative implementations.

See #39210, #51678, #26511.

git-svn-id: https://develop.svn.wordpress.org/trunk@49566 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dominik Schilling
2020-11-12 14:41:19 +00:00
parent e8e031d2dd
commit 4006c07417
30 changed files with 134 additions and 605 deletions
@@ -2,20 +2,18 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"POT-Creation-Date: 2015-12-31 16:31+0100\n"
"PO-Revision-Date: 2020-10-20 17:11+0200\n"
"PO-Revision-Date: 2016-10-26 00:02+0200\n"
"Language: de_DE\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 2.4.1\n"
"X-Generator: Poedit 1.8.10\n"
"X-Poedit-Basepath: .\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Poedit-KeywordsList: __;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;"
"_nx_noop:1,2,3c;esc_attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;"
"esc_html_x:1,2c\n"
"X-Textdomain-Support: yes\n"
"Language-Team: \n"
"Last-Translator: \n"
"X-Poedit-SearchPath-0: .\n"
#: internationalized-plugin.php:11
@@ -1,23 +0,0 @@
msgid ""
msgstr ""
"Project-Id-Version: \n"
"POT-Creation-Date: 2015-12-31 16:31+0100\n"
"PO-Revision-Date: 2020-10-20 17:12+0200\n"
"Language: de_DE\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 2.4.1\n"
"X-Poedit-Basepath: .\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Poedit-KeywordsList: __;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;"
"_nx_noop:1,2,3c;esc_attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;"
"esc_html_x:1,2c\n"
"X-Textdomain-Support: yes\n"
"Language-Team: \n"
"Last-Translator: \n"
"X-Poedit-SearchPath-0: .\n"
#: internationalized-plugin.php:11
msgid "This is a dummy plugin"
msgstr "Este es un plugin dummy"
@@ -2,20 +2,18 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"POT-Creation-Date: 2015-12-31 16:38+0100\n"
"PO-Revision-Date: 2020-10-20 17:09+0200\n"
"PO-Revision-Date: 2016-10-26 00:02+0200\n"
"Language: de_DE\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 2.4.1\n"
"X-Generator: Poedit 1.8.10\n"
"X-Poedit-Basepath: .\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Poedit-KeywordsList: __;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;"
"_nx_noop:1,2,3c;esc_attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;"
"esc_html_x:1,2c\n"
"X-Textdomain-Support: yes\n"
"Last-Translator: \n"
"Language-Team: \n"
"X-Poedit-SearchPath-0: .\n"
#: functions.php:7
@@ -1,14 +0,0 @@
<?php
/*
Plugin Name: Custom Dummy Plugin
Plugin URI: https://wordpress.org/
Description: For testing purposes only.
Version: 1.0.0
Text Domain: custom-internationalized-plugin
*/
load_plugin_textdomain( 'custom-internationalized-plugin', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
function custom_i18n_plugin_test() {
return __( 'This is a dummy plugin', 'custom-internationalized-plugin' );
}
@@ -1,23 +0,0 @@
msgid ""
msgstr ""
"Project-Id-Version: \n"
"POT-Creation-Date: 2015-12-31 16:31+0100\n"
"PO-Revision-Date: 2020-10-20 17:09+0200\n"
"Language: de_DE\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 2.4.1\n"
"X-Poedit-Basepath: .\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Poedit-KeywordsList: __;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;"
"_nx_noop:1,2,3c;esc_attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;"
"esc_html_x:1,2c\n"
"X-Textdomain-Support: yes\n"
"Last-Translator: Dominik Schilling\n"
"Language-Team: \n"
"X-Poedit-SearchPath-0: .\n"
#: internationalized-plugin.php:11
msgid "This is a dummy plugin"
msgstr "Das ist ein Dummy Plugin"
@@ -1,23 +0,0 @@
msgid ""
msgstr ""
"Project-Id-Version: \n"
"POT-Creation-Date: 2015-12-31 16:31+0100\n"
"PO-Revision-Date: 2020-10-20 17:09+0200\n"
"Language: es_ES\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 2.4.1\n"
"X-Poedit-Basepath: .\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Poedit-KeywordsList: __;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;"
"_nx_noop:1,2,3c;esc_attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;"
"esc_html_x:1,2c\n"
"X-Textdomain-Support: yes\n"
"Last-Translator: Dominik Schilling\n"
"Language-Team: \n"
"X-Poedit-SearchPath-0: .\n"
#: internationalized-plugin.php:11
msgid "This is a dummy plugin"
msgstr "Este es un plugin dummy"
+4 -1
View File
@@ -4,8 +4,11 @@ Plugin Name: Hello Dolly
Plugin URI: http://wordpress.org/#
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.
Author: Matt Mullenweg
Version: 1.7.2
Version: 1.5.1
Author URI: http://ma.tt/
Text Domain: hello-dolly
*/
// Test for
?>
@@ -1,10 +0,0 @@
<?php
/**
* Dummy theme.
*/
load_theme_textdomain( 'custom-internationalized-theme', get_template_directory() . '/languages' );
function custom_i18n_theme_test() {
return __( 'This is a dummy theme', 'custom-internationalized-theme' );
}
@@ -1,4 +0,0 @@
<?php
/**
* Dummy theme.
*/
@@ -1,23 +0,0 @@
msgid ""
msgstr ""
"Project-Id-Version: \n"
"POT-Creation-Date: 2015-12-31 16:38+0100\n"
"PO-Revision-Date: 2020-10-20 17:11+0200\n"
"Language: de_DE\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 2.4.1\n"
"X-Poedit-Basepath: .\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Poedit-KeywordsList: __;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;"
"_nx_noop:1,2,3c;esc_attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;"
"esc_html_x:1,2c\n"
"X-Textdomain-Support: yes\n"
"Last-Translator: \n"
"Language-Team: \n"
"X-Poedit-SearchPath-0: .\n"
#: functions.php:7
msgid "This is a dummy theme"
msgstr "Das ist ein Dummy Theme"
@@ -1,23 +0,0 @@
msgid ""
msgstr ""
"Project-Id-Version: \n"
"POT-Creation-Date: 2015-12-31 16:38+0100\n"
"PO-Revision-Date: 2020-10-20 17:10+0200\n"
"Language: es_ES\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 2.4.1\n"
"X-Poedit-Basepath: .\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Poedit-KeywordsList: __;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;"
"_nx_noop:1,2,3c;esc_attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;"
"esc_html_x:1,2c\n"
"X-Textdomain-Support: yes\n"
"Last-Translator: \n"
"Language-Team: \n"
"X-Poedit-SearchPath-0: .\n"
#: functions.php:7
msgid "This is a dummy theme"
msgstr "Este es un tema dummy"
@@ -1,7 +0,0 @@
/*
Theme Name: Custom Internationalized Theme
Theme URI: https://wordpress.org/
Description: For testing purposes only.
Version: 1.0.0
Text Domain: custom-internationalized-theme
*/
+8 -42
View File
@@ -37,11 +37,6 @@ if ( ! is_readable( $config_file_path ) ) {
require_once $config_file_path;
require_once __DIR__ . '/functions.php';
if ( defined( 'WP_RUN_CORE_TESTS' ) && WP_RUN_CORE_TESTS && ! is_dir( ABSPATH ) ) {
echo "Error: The /build/ directory is missing! Please run `npm run build` prior to running PHPUnit.\n";
exit( 1 );
}
$phpunit_version = tests_get_phpunit_version();
if ( version_compare( $phpunit_version, '5.4', '<' ) || version_compare( $phpunit_version, '8.0', '>=' ) ) {
@@ -53,23 +48,8 @@ if ( version_compare( $phpunit_version, '5.4', '<' ) || version_compare( $phpuni
exit( 1 );
}
$required_extensions = array(
'gd',
);
$missing_extensions = array();
foreach ( $required_extensions as $extension ) {
if ( ! extension_loaded( $extension ) ) {
$missing_extensions[] = $extension;
}
}
if ( $missing_extensions ) {
printf(
"Error: The following required PHP extensions are missing from the testing environment: %s.\n",
implode( ', ', $missing_extensions )
);
echo "Please make sure they are installed and enabled.\n",
if ( defined( 'WP_RUN_CORE_TESTS' ) && WP_RUN_CORE_TESTS && ! is_dir( ABSPATH ) ) {
echo "Error: The /build/ directory is missing! Please run `npm run build` prior to running PHPUnit.\n";
exit( 1 );
}
@@ -79,34 +59,24 @@ $required_constants = array(
'WP_TESTS_TITLE',
'WP_PHP_BINARY',
);
$missing_constants = array();
foreach ( $required_constants as $constant ) {
if ( ! defined( $constant ) ) {
$missing_constants[] = $constant;
printf(
"Error: The required %s constant is not defined. Check out `wp-tests-config-sample.php` for an example.\n",
$constant
);
exit( 1 );
}
}
if ( $missing_constants ) {
printf(
"Error: The following required constants are not defined: %s.\n",
implode( ', ', $missing_constants )
);
echo "Please check out `wp-tests-config-sample.php` for an example.\n",
exit( 1 );
}
tests_reset__SERVER();
define( 'WP_TESTS_TABLE_PREFIX', $table_prefix );
define( 'DIR_TESTDATA', __DIR__ . '/../data' );
define( 'DIR_TESTROOT', realpath( dirname( __DIR__ ) ) );
define( 'WP_LANG_DIR', realpath( DIR_TESTDATA . '/languages' ) );
if ( defined( 'WP_RUN_CORE_TESTS' ) && WP_RUN_CORE_TESTS ) {
define( 'WP_PLUGIN_DIR', realpath( DIR_TESTDATA . '/plugins' ) );
}
define( 'WP_LANG_DIR', DIR_TESTDATA . '/languages' );
if ( ! defined( 'WP_TESTS_FORCE_KNOWN_BUGS' ) ) {
define( 'WP_TESTS_FORCE_KNOWN_BUGS', false );
@@ -170,10 +140,6 @@ $GLOBALS['_wp_die_disabled'] = false;
tests_add_filter( 'wp_die_handler', '_wp_die_handler_filter' );
// Use the Spy REST Server instead of default.
tests_add_filter( 'wp_rest_server_class', '_wp_rest_server_class_filter' );
// Prevent updating translations asynchronously.
tests_add_filter( 'async_update_translation', '__return_false' );
// Disable background updates.
tests_add_filter( 'automatic_updater_disabled', '__return_true' );
// Preset WordPress options defined in bootstrap file.
// Used to activate themes, plugins, as well as other settings.
+1 -1
View File
@@ -14,7 +14,7 @@ class Tests_Admin_includesPlugin extends WP_UnitTestCase {
'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 Hello, Dolly in the upper right of your admin screen on every page. <cite>By <a href="http://ma.tt/">Matt Mullenweg</a>.</cite>',
'Author' => '<a href="http://ma.tt/">Matt Mullenweg</a>',
'AuthorURI' => 'http://ma.tt/',
'Version' => '1.7.2',
'Version' => '1.5.1',
'TextDomain' => 'hello-dolly',
'DomainPath' => '',
);
+5 -15
View File
@@ -24,22 +24,12 @@ class Tests_L10n_loadTextdomain extends WP_UnitTestCase {
add_filter( 'plugin_locale', array( $this, 'store_locale' ) );
add_filter( 'theme_locale', array( $this, 'store_locale' ) );
/** @var WP_Textdomain_Registry $wp_textdomain_registry */
global $wp_textdomain_registry;
$wp_textdomain_registry->reset();
}
public function tearDown() {
remove_filter( 'plugin_locale', array( $this, 'store_locale' ) );
remove_filter( 'theme_locale', array( $this, 'store_locale' ) );
/** @var WP_Textdomain_Registry $wp_textdomain_registry */
global $wp_textdomain_registry;
$wp_textdomain_registry->reset();
parent::tearDown();
}
@@ -126,13 +116,13 @@ class Tests_L10n_loadTextdomain extends WP_UnitTestCase {
/**
* @ticket 21319
*/
public function test_is_textdomain_is_not_loaded_after_gettext_call_with_no_translations() {
function test_is_textdomain_is_not_loaded_after_gettext_call_with_no_translations() {
$this->assertFalse( is_textdomain_loaded( 'wp-tests-domain' ) );
__( 'just some string', 'wp-tests-domain' );
$this->assertFalse( is_textdomain_loaded( 'wp-tests-domain' ) );
}
public function test_override_load_textdomain_noop() {
function test_override_load_textdomain_noop() {
add_filter( 'override_load_textdomain', '__return_true' );
$load_textdomain = load_textdomain( 'wp-tests-domain', DIR_TESTDATA . '/non-existent-file' );
remove_filter( 'override_load_textdomain', '__return_true' );
@@ -141,7 +131,7 @@ class Tests_L10n_loadTextdomain extends WP_UnitTestCase {
$this->assertFalse( is_textdomain_loaded( 'wp-tests-domain' ) );
}
public function test_override_load_textdomain_non_existent_mofile() {
function test_override_load_textdomain_non_existent_mofile() {
add_filter( 'override_load_textdomain', array( $this, '_override_load_textdomain_filter' ), 10, 3 );
$load_textdomain = load_textdomain( 'wp-tests-domain', WP_LANG_DIR . '/non-existent-file.mo' );
remove_filter( 'override_load_textdomain', array( $this, '_override_load_textdomain_filter' ) );
@@ -155,7 +145,7 @@ class Tests_L10n_loadTextdomain extends WP_UnitTestCase {
$this->assertFalse( $is_textdomain_loaded_after );
}
public function test_override_load_textdomain_custom_mofile() {
function test_override_load_textdomain_custom_mofile() {
add_filter( 'override_load_textdomain', array( $this, '_override_load_textdomain_filter' ), 10, 3 );
$load_textdomain = load_textdomain( 'wp-tests-domain', WP_LANG_DIR . '/plugins/internationalized-plugin-de_DE.mo' );
remove_filter( 'override_load_textdomain', array( $this, '_override_load_textdomain_filter' ) );
@@ -175,7 +165,7 @@ class Tests_L10n_loadTextdomain extends WP_UnitTestCase {
* @param string $file Path to the MO file.
* @return bool
*/
public function _override_load_textdomain_filter( $override, $domain, $file ) {
function _override_load_textdomain_filter( $override, $domain, $file ) {
global $l10n;
if ( ! is_readable( $file ) ) {
@@ -32,12 +32,10 @@ class Tests_L10n_loadTextdomainJustInTime extends WP_UnitTestCase {
add_filter( 'stylesheet_root', array( $this, 'filter_theme_root' ) );
add_filter( 'template_root', array( $this, 'filter_theme_root' ) );
wp_clean_themes_cache();
unset( $GLOBALS['wp_themes'], $GLOBALS['l10n'], $GLOBALS['l10n_unloaded'] );
/** @var WP_Textdomain_Registry $wp_textdomain_registry */
global $wp_textdomain_registry;
$wp_textdomain_registry->reset();
unset( $GLOBALS['wp_themes'] );
unset( $GLOBALS['l10n'] );
unset( $GLOBALS['l10n_unloaded'] );
_get_path_to_translation( null, true );
}
public function tearDown() {
@@ -46,12 +44,10 @@ class Tests_L10n_loadTextdomainJustInTime extends WP_UnitTestCase {
remove_filter( 'stylesheet_root', array( $this, 'filter_theme_root' ) );
remove_filter( 'template_root', array( $this, 'filter_theme_root' ) );
wp_clean_themes_cache();
unset( $GLOBALS['wp_themes'], $GLOBALS['l10n'], $GLOBALS['l10n_unloaded'] );
/** @var WP_Textdomain_Registry $wp_textdomain_registry */
global $wp_textdomain_registry;
$wp_textdomain_registry->reset();
unset( $GLOBALS['wp_themes'] );
unset( $GLOBALS['l10n'] );
unset( $GLOBALS['l10n_unloaded'] );
_get_path_to_translation( null, true );
parent::tearDown();
}
@@ -174,7 +170,6 @@ class Tests_L10n_loadTextdomainJustInTime extends WP_UnitTestCase {
/**
* @ticket 37997
* @ticket 39210
*/
public function test_plugin_translation_after_switching_locale_twice() {
require_once DIR_TESTDATA . '/plugins/internationalized-plugin.php';
@@ -188,7 +183,7 @@ class Tests_L10n_loadTextdomainJustInTime extends WP_UnitTestCase {
restore_current_locale();
$this->assertSame( 'Das ist ein Dummy Plugin', $expected_de_de );
$this->assertSame( 'Este es un plugin dummy', $expected_es_es );
$this->assertSame( 'This is a dummy plugin', $expected_es_es );
}
/**
+6 -83
View File
@@ -22,21 +22,15 @@ class Tests_Locale_Switcher extends WP_UnitTestCase {
$this->locale = '';
$this->previous_locale = '';
unset( $GLOBALS['l10n'], $GLOBALS['l10n_unloaded'] );
/** @var WP_Textdomain_Registry $wp_textdomain_registry */
global $wp_textdomain_registry;
$wp_textdomain_registry->reset();
unset( $GLOBALS['l10n'] );
unset( $GLOBALS['l10n_unloaded'] );
_get_path_to_translation( null, true );
}
public function tearDown() {
unset( $GLOBALS['l10n'], $GLOBALS['l10n_unloaded'] );
/** @var WP_Textdomain_Registry $wp_textdomain_registry */
global $wp_textdomain_registry;
$wp_textdomain_registry->reset();
unset( $GLOBALS['l10n'] );
unset( $GLOBALS['l10n_unloaded'] );
_get_path_to_translation( null, true );
parent::tearDown();
}
@@ -394,77 +388,6 @@ class Tests_Locale_Switcher extends WP_UnitTestCase {
$this->assertSame( 'This is a dummy plugin', $expected );
}
/**
* @ticket 39210
*/
public function test_switch_reloads_plugin_translations_outside_wp_lang_dir() {
global $wp_locale_switcher, $wp_textdomain_registry;
$locale_switcher = clone $wp_locale_switcher;
$wp_locale_switcher = new WP_Locale_Switcher();
$wp_locale_switcher->init();
require_once DIR_TESTDATA . '/plugins/custom-internationalized-plugin/custom-internationalized-plugin.php';
$this->assertSame( WP_PLUGIN_DIR . '/custom-internationalized-plugin/languages/', $wp_textdomain_registry->get( 'custom-internationalized-plugin' ) );
$expected = custom_i18n_plugin_test();
$this->assertSame( 'This is a dummy plugin', $expected );
switch_to_locale( 'es_ES' );
switch_to_locale( 'de_DE' );
$expected = custom_i18n_plugin_test();
$this->assertSame( 'Das ist ein Dummy Plugin', $expected );
restore_previous_locale();
$expected = custom_i18n_plugin_test();
$this->assertSame( 'Este es un plugin dummy', $expected );
restore_current_locale();
$wp_locale_switcher = $locale_switcher;
}
/**
* @ticket 39210
*/
public function test_switch_reloads_theme_translations_outside_wp_lang_dir() {
global $wp_locale_switcher, $wp_textdomain_registry;
$locale_switcher = clone $wp_locale_switcher;
$wp_locale_switcher = new WP_Locale_Switcher();
$wp_locale_switcher->init();
switch_theme( 'custom-internationalized-theme' );
require_once get_stylesheet_directory() . '/functions.php';
$this->assertSame( get_template_directory() . '/languages/', $wp_textdomain_registry->get( 'custom-internationalized-theme' ) );
$expected = custom_i18n_theme_test();
$this->assertSame( 'This is a dummy theme', $expected );
switch_to_locale( 'es_ES' );
switch_to_locale( 'de_DE' );
$expected = custom_i18n_theme_test();
$this->assertSame( 'Das ist ein Dummy Theme', $expected );
restore_previous_locale();
$expected = custom_i18n_theme_test();
$this->assertSame( 'Este es un tema dummy', $expected );
restore_current_locale();
$wp_locale_switcher = $locale_switcher;
}
public function filter_locale() {
return 'es_ES';
}
-1
View File
@@ -162,7 +162,6 @@ class Tests_Theme_ThemeDir extends WP_UnitTestCase {
'Page Template Theme', // Theme with page templates for other test code.
'Theme with Spaces in the Directory',
'Internationalized Theme',
'Custom Internationalized Theme',
'camelCase',
'REST Theme',
);