Supporting mixed text directions

:bookmark: This document explains what the “support mixed text direction” setting does in Discourse, how it works, and how it impacts post composition.

:person_raising_hand: Required user level: Administrator

The ‘support mixed text direction’ setting is crucial for sites that feature both left-to-right (LTR) and right-to-left (RTL) languages. Enabling this setting ensures that Discourse automatically adjusts the text direction for various elements like post content, topic titles, category names, and the composer’s preview area based on the language detected. Additionally, it sets the text direction for text inputs according to the user’s language input. As long as the content is separated by a newline, it allows you to have mixed text within an individual post.


This documentation will cover:

  • How the ‘support mixed text direction’ setting works
  • Its impact on content display
  • How it affects post composition
  • Best practices and common issues

How it works

The support mixed text direction setting only affects the content’s display in the browser. It doesn’t alter the content stored in the database. The text direction is determined through a regular expression that evaluates the language used. The appropriate dir attribute is then added to the text’s outer HTML tag.

:information_source: While setting dir="auto" could achieve similar results, this method isn’t compatible with Internet Explorer (IE) browsers, making the regular expression approach necessary.

Composing a post

When composing a post, the text entered in the textarea of the composer defaults to the user’s preferred locale’s direction. This means that the textarea input supports only one text direction at a time. To assist with mixed text direction needs, the setting introduces a Toggle Direction button in the composer’s toolbar. Clicking this button switches the direction of the entire textarea.

In the composer’s preview area, the text will display with the correct direction regardless of the textarea’s current direction.

Best practices

  1. Enable this setting if your community frequently uses both LTR and RTL languages.
  2. Use the Toggle Direction button to adjust text direction when composing posts to ensure readability.
  3. Inform users about the Toggle Direction button for better usability in mixed-language posts.

Common issues and solutions

  1. Text alignment not appearing correctly: Ensure the setting is enabled. If issues persist, verify that the language script is consistently recognized by the regular expression.
  2. Internet Explorer compatibility: Remember that dir="auto" is unsupported in IE browsers. Stick to the provided functionality for consistent results.


Q: What happens if the setting is disabled?
A: Text direction will not automatically adjust based on the language, which can cause readability issues in mixed-language posts.

Q: Does it change the actual content in the database?
A: No, it only affects how content is displayed in the browser.

Q: Can I manually set text direction without this setting?
A: Yes, but enabling this setting simplifies the process and ensures consistency across the site.

Last edited by @hugh 2024-06-17T10:21:14Z

Last checked by @hugh 2024-06-17T10:21:21Z

Check documentPerform check on document: