mirror of
git://develop.git.wordpress.org/
synced 2025-01-17 12:58:25 +01:00
Fix wp.i18n.isRTL()
Fixes a bug causing wp.i18n.isRTL() to return false in RTL langauges by manually loading the translated 'ltr' string for the i18n dependency. This ports over an identical fix that was made in Gutenberg. Fixes #52441. Props @jonsurrell @youknowriad. git-svn-id: https://develop.svn.wordpress.org/trunk@50259 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
27a113951b
commit
385c29b49a
14
package-lock.json
generated
14
package-lock.json
generated
@ -3931,6 +3931,14 @@
|
||||
"tar-fs": "^2.0.0",
|
||||
"unbzip2-stream": "^1.3.3",
|
||||
"ws": "^7.2.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"devtools-protocol": {
|
||||
"version": "0.0.818844",
|
||||
"resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.818844.tgz",
|
||||
"integrity": "sha512-AD1hi7iVJ8OD0aMLQU5VK0XH9LDlA1+BcPIgrAxPfaibx2DbWucuyOhc4oyQCbnvDDO68nN6/LcKfqTP343Jjg==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"rimraf": {
|
||||
@ -8058,12 +8066,6 @@
|
||||
"integrity": "sha512-ZIzRpLJrOj7jjP2miAtgqIfmzbxa4ZOr5jJc601zklsfEx9oTzmmj2nVpIPRpNlRTIh8lc1kyViIY7BWSGNmKw==",
|
||||
"dev": true
|
||||
},
|
||||
"devtools-protocol": {
|
||||
"version": "0.0.818844",
|
||||
"resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.818844.tgz",
|
||||
"integrity": "sha512-AD1hi7iVJ8OD0aMLQU5VK0XH9LDlA1+BcPIgrAxPfaibx2DbWucuyOhc4oyQCbnvDDO68nN6/LcKfqTP343Jjg==",
|
||||
"dev": true
|
||||
},
|
||||
"diff": {
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz",
|
||||
|
@ -267,6 +267,18 @@ function wp_default_packages_scripts( $scripts ) {
|
||||
if ( in_array( 'wp-i18n', $dependencies, true ) ) {
|
||||
$scripts->set_translations( $handle );
|
||||
}
|
||||
|
||||
// Manually set the text direction localization after wp-i18n is
|
||||
// printed. This ensures that wp.i18n.isRTL() returns true in RTL
|
||||
// languages. We cannot use $scripts->set_translations( 'wp-i18n' ) to
|
||||
// do this because WordPress prints a script's translations *before*
|
||||
// printing the script, which means, in the case of wp-i18n, that
|
||||
// wp.i18n.setLocaleData() is called before wp.i18n is defined.
|
||||
if ( 'wp-i18n' === $handle ) {
|
||||
$ltr = _x( 'ltr', 'text direction', 'default' );
|
||||
$script = sprintf( "wp.i18n.setLocaleData( { 'text direction\u0004ltr': [ '%s' ] } );", $ltr );
|
||||
$scripts->add_inline_script( $handle, $script, 'after' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -723,6 +723,9 @@ JS;
|
||||
$expected .= "<script type='text/javascript' src='/wp-includes/js/dist/dom-ready{$suffix}.js' id='wp-dom-ready-js'></script>\n";
|
||||
$expected .= "<script type='text/javascript' src='/wp-includes/js/dist/hooks{$suffix}.js' id='wp-hooks-js'></script>\n";
|
||||
$expected .= "<script type='text/javascript' src='/wp-includes/js/dist/i18n{$suffix}.js' id='wp-i18n-js'></script>\n";
|
||||
$expected .= "<script type='text/javascript' id='wp-i18n-js-after'>\n";
|
||||
$expected .= "wp.i18n.setLocaleData( { 'text direction\u0004ltr': [ 'ltr' ] } );\n";
|
||||
$expected .= "</script>\n";
|
||||
$expected .= "<script type='text/javascript' id='wp-a11y-js-translations'>\n";
|
||||
$expected .= "( function( domain, translations ) {\n";
|
||||
$expected .= " var localeData = translations.locale_data[ domain ] || translations.locale_data.messages;\n";
|
||||
|
Loading…
x
Reference in New Issue
Block a user