Make WordPress Core

Opened 16 years ago

Closed 13 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's profile RanYanivHartstein Owned by: nbachiyski's profile nbachiyski
Milestone: 3.1 Priority: normal
Severity: minor Version: 3.0
Component: I18N Keywords: has-patch dev-feedback
Focuses: Cc:


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 15 years ago.
functions.php.patch (1.4 KB) - added by RanYanivHartstein 14 years ago.
RTL fix for wp_die()

Download all attachments as: .zip

Change History (18)

#1 @lloydbudd
16 years ago

  • Milestone set to 2.6

All open tickets should have a milestone.

#2 @nbachiyski
16 years ago

  • Owner changed from anonymous to nbachiyski

#3 @nbachiyski
15 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.

#4 @nbachiyski
15 years ago

  • Keywords has-patch added

#5 @Denis-de-Bernardy
15 years ago

  • Keywords dev-feedback added

#6 @Denis-de-Bernardy
15 years ago

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

#7 @ryan
15 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

#8 @RanYanivHartstein
14 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:

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.

14 years ago

RTL fix for wp_die()

#9 follow-up: @nacin
14 years ago

  • Milestone changed from 2.8 to 3.1

#10 in reply to: ↑ 9 @RanYanivHartstein
14 years ago

Replying to nacin:

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

#11 @nacin
14 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?

#12 @tomer
14 years ago

  • Cc tomer added

#13 @RanYanivHartstein
14 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.

#14 @hakre
14 years ago

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

#15 @nacin
13 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.

#16 @nbachiyski
13 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.