Make WordPress Core

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#19924 closed defect (bug) (fixed)

An RTL WPLANG results in RTL even if messages are not loaded

Reported by: nacin Owned by: nacin
Milestone: 3.4 Priority: normal
Severity: normal Version:
Component: I18N Keywords: has-patch
Focuses: Cc:


define( 'WPLANG', 'he_IL' ); in wp-config.php results in get_locale() returning 'he_IL', and he_IL.mo will attempt to be loaded, as will he_IL.php.

he_IL.php previously set $text_direction = 'rtl'; It is a reasonable assumption that if he_IL.php is installed in WP_LANG_DIR, then so is he_IL.mo.

The new RTL detection code introduced in #19600 acts without the need for he_IL.php.

While I would consider it an incorrect configuration to have WPLANG = he_IL, I imagine there are some installations out there with an RTL WPLANG but no language files to trigger it. Normally, this would result in an English interface, but now, this would result in an English interface in RTL mode.

Maybe this is more edge than I am anticipating, but perhaps an is_readable() check of the $locale.mo file would make sense before trusting WP_Locale::is_locale_rtl().

We could give load_default_textdomain() a return value of its first load_textdomain() call, and then decide to not even load the $locale.php file or trigger an RTL switch.

Attachments (3)

19924.diff (3.0 KB) - added by nacin 9 years ago.
19924.patch (467 bytes) - added by SergeyBiryukov 9 years ago.
19924.2.diff (1.9 KB) - added by nacin 9 years ago.

Download all attachments as: .zip

Change History (10)

9 years ago

#1 @nacin
9 years ago

  • Keywords has-patch added

Took a crack at my initial line of thought.

#2 @nacin
9 years ago

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

In [19797]:

Only set text_direction based on a locale being RTL if we successfully loaded a locale.mo file. Otherwise we may be in RTL land based on a WPLANG constant but nothing else. fixes #19924.

#3 @SergeyBiryukov
9 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

Part of [19797] has broken $locale.php inclusion on Windows. 19924.patch fixes that.

validate_file() for S:\home\wordpress\trunk/wp-content/languages/ru_RU.php returns 2.

#4 @nacin
9 years ago

Hm. Okay. Guess it wasn't a typo after all.

#5 @nacin
9 years ago

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

In [19824]:

WP_LANG_DIR is trusted, just need to check $locale. props SergeyBiryukov, fixes #19924.

9 years ago

#6 @nacin
9 years ago

19924.2.diff is a more straightforward solution to these various problems.

#7 @nacin
9 years ago

In [19836]:

Do RTL detection based on a translated string, rather than a hardcoded list. Makes things a bit cleaner. fixes #19924, fixes #19600.

Note: See TracTickets for help on using tickets.