WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 3 years ago

#6132 closed defect (bug) (fixed)

Error message in wp-blog-header.php can't be RTLed even if locale is set

Reported by: RanYanivHartstein Owned by: nbachiyski
Milestone: 3.1 Priority: normal
Severity: minor Version: 3.0
Component: I18N Keywords: has-patch dev-feedback
Focuses: Cc:

Description

The wp_die function checks for the $text_direction variable to set directionality in error messages, however when there is no wp-config.php file, the error message in wp-blog-header.php is shown - but since there is no wp-config.php file, the locale files don't get loaded and the error message isn't RTLed.

I hope this wasn't too convoluted an explanation, it's a bit of a paradoxical situation that's hard to explain...

Attachments (2)

i18n-rtl-no-config.diff (2.7 KB) - added by nbachiyski 5 years ago.
functions.php.patch (1.4 KB) - added by RanYanivHartstein 4 years ago.
RTL fix for wp_die()

Download all attachments as: .zip

Change History (18)

comment:1 lloydbudd6 years ago

  • Milestone set to 2.6

All open tickets should have a milestone.

comment:2 nbachiyski6 years ago

  • Owner changed from anonymous to nbachiyski

comment:3 nbachiyski5 years ago

  • Milestone changed from 2.9 to 2.8

Here is a solution, but it will work only for the local package. Since we already change some hardcoded error messages in the files, we can change the text direction, too.

The patch passes another argument to wp_die(), the text direction. The value is taken from a string will appear in your POT file and will be replaced when the local version is generated.

comment:4 nbachiyski5 years ago

  • Keywords has-patch added

comment:5 Denis-de-Bernardy5 years ago

  • Keywords dev-feedback added

comment:6 Denis-de-Bernardy5 years ago

there is another ticket that related to a notice fix, on the same issue: #9370

comment:7 ryan5 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [11408]) Pass text direction to wp_die(). Allow locales to set text direction in local packages. Props nbachiyski. fixes #6132

comment:8 RanYanivHartstein4 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened
  • Version set to 3.0

This problem still exists as of version 3.0.

To reproduce this bug, you can download the latest version of WordPress Hebrew, from here: http://he.wordpress.org/wordpress-3.0-he_IL.zip

Simply unzip and try to run it in your server. The standard "no wp-config.php file" error message will be displayed, translated to Hebrew, but not be RTLed. This applies to some other wp_die() error messages, but this is the easiest to reproduce.

Since the "no wp-config.php file" error is actually the first stage of the automatic WordPress installer, this reflects poorly on WordPress when used in RTL locales.

This happens because wp_die relies on the language_attributes() function to set the RTL attribute on the HTML tag. Because wp_die() can be called before language_attributes() is loaded (indeed, it can be called the locale is even set), some error messages don't actually get RTLed.

I'm including a patch with a possible fix. It replaces language_attributes() and adds an RTL attribute to the HTML tag when appropriate. It utilizes the same method to determine directionality as proposed by nbachiyski.

This patch was tested on WordPress Hebrew 3.0, which is an RTL language.

RanYanivHartstein4 years ago

RTL fix for wp_die()

comment:9 follow-up: nacin4 years ago

  • Milestone changed from 2.8 to 3.1

comment:10 in reply to: ↑ 9 RanYanivHartstein4 years ago

Replying to nacin:

This is a pretty simple fix - can't this be done for 3.0.1?

comment:11 nacin4 years ago

It's been around since 2.8, so we probably won't rush it into 3.0.1.

Patch feedback: Looks good, but we should probably still rely on language_attributes() if both it and is_rtl() is defined. Thus:

if ( function_exists( 'language_attributes' ) && function_exists( 'is_rtl' ) ) language_attributes(); else echo "dir='$text_direction'";

That look about right?

comment:12 tomer4 years ago

  • Cc tomer added

comment:13 RanYanivHartstein4 years ago

  • Severity changed from normal to minor

Don't know why this hasn't occurred to me earlier, but since these messages are in HTML, they can be easily RTLed during the translation. An automatic RTL function would still be appreciated, but it's definitely not urgent. I changed "Severity" to minor.

comment:14 hakre3 years ago

It's been around since 2.8, so we probably can slowly make this into 3.1, right?

comment:15 nacin3 years ago

  • Milestone changed from Awaiting Triage to 3.1

Final patch looks sane. My snippet that follows it is probably a more complete solution.

comment:16 nbachiyski3 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

(In [16392]) Fallback to only RTL attributes in wp_die()'s HTML tag if it's very early in the execution. Fixes #6132. Props RanYanivHartstein and nacin.

Note: See TracTickets for help on using tickets.