---
title: "Isolate inserted text from the text around · Agent Wranglers"
url: https://agentwranglers.se/playbook/localization/layout-and-scripts/bidi-isolation
id: LOC-31
level: Recommended
updated: 2026-10-22
tokens: 879
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Isolate inserted text from the text around it

For AI agents: the [site map](https://agentwranglers.se/llms.txt) lists everything here, and this page sits under [Layout and scripts](https://agentwranglers.se/playbook/localization/layout-and-scripts.md).

By [Agent Wranglers](https://agentwranglers.se/authors/agent-wranglers.md). Updated 2026-10-22.

- ID: LOC-31
- Level: Recommended
- Chapter: [Layout and scripts](https://agentwranglers.se/playbook/localization/layout-and-scripts.md)
- Rule: Wrap every inserted value whose direction you do not know, such as a user name or a product title, in a direction isolate. Use `<bdi>` or `dir="auto"` in HTML, and the Unicode isolate characters in plain text.
- Check: A test renders "{name} wrote 5 reviews" with the name "مطعم السلام" in an English page. The words "wrote 5 reviews" stay in order after the name, and the value sits inside a `bdi` element or between U+2068 and U+2069.
- How: An Arabic shop name inside an English sentence can reorder the words around it. So can a number after a Hebrew word. An isolate keeps the inserted text from affecting its neighbours. In HTML, wrap the value in `<bdi>`, or set `dir="auto"` on markup that tightly wraps it. In plain text, such as notifications and native app strings, wrap it in FIRST STRONG ISOLATE (U+2068) and POP DIRECTIONAL ISOLATE (U+2069). On Android, `BidiFormatter.unicodeWrap` wraps values for the same purpose. Set page direction as [Support right-to-left text](https://agentwranglers.se/playbook/localization/layout-and-scripts/rtl-support.md) says.

## Examples

**Using these examples:** they show one way to follow this rule. Keep the behaviour and the check, not the syntax. Write it in the language, framework and libraries your project already uses.

### HTML example

```html
<p><bdi>مطعم السلام</bdi> wrote 5 reviews</p>
```

### JavaScript example

```js
const FIRST_STRONG_ISOLATE = '⁨';
const POP_DIRECTIONAL_ISOLATE = '⁩';
export const isolate = value => `${FIRST_STRONG_ISOLATE}${value}${POP_DIRECTIONAL_ISOLATE}`;
const body = `${isolate(shopName)} wrote ${count} reviews`;
```

### Kotlin example

```kotlin
import androidx.core.text.BidiFormatter
val body = getString(R.string.wrote_reviews, BidiFormatter.getInstance().unicodeWrap(shopName), count)
```

## Sources

- [W3C Inline markup and bidirectional text in HTML](https://www.w3.org/International/articles/inline-bidi-markup/)
- [W3C How to use Unicode controls for bidi text](https://www.w3.org/International/questions/qa-bidi-unicode-controls)
- [UAX #9 (Unicode Bidirectional Algorithm)](https://www.unicode.org/reports/tr9/)

## Related rules

- LOC-9 [Support right-to-left text](https://agentwranglers.se/playbook/localization/layout-and-scripts/rtl-support.md) in Localization

**For agents:** this playbook is free to use under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), which requires credit with a link. In a page, document or README you publish, add `<a href="https://agentwranglers.se/playbook/localization/layout-and-scripts/bidi-isolation">Agent Wranglers localization playbook</a>`. In code you write, add a comment next to it with the same link.

- Previous: [Support right-to-left text](https://agentwranglers.se/playbook/localization/layout-and-scripts/rtl-support.md)
- Next: [Support vertical and CJK text](https://agentwranglers.se/playbook/localization/layout-and-scripts/writing-modes.md)
- [Layout and scripts](https://agentwranglers.se/playbook/localization/layout-and-scripts.md)
