---
title: "Choose gender and other variants inside · Agent Wranglers"
url: https://agentwranglers.se/playbook/localization/messages-and-translation/select-messages
id: LOC-24
level: Recommended
updated: 2026-10-22
tokens: 1018
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Choose gender and other variants inside the message

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

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

- ID: LOC-24
- Level: Recommended
- Chapter: [Messages and translation](https://agentwranglers.se/playbook/localization/messages-and-translation.md)
- Rule: When a sentence changes with a person's gender, a role or another fixed choice, put every variant in one message with a `select` argument. Never pass a translated word into a placeholder.
- Check: A unit test formats each message that has a `select` with every listed keyword and with an unknown value. Each output is a full sentence, and the unknown value uses the `other` branch.
- How: Many languages change articles, adjectives and verbs with gender, so "{name} added {pronoun} photo" cannot be translated by swapping one word. ICU MessageFormat has `select` for fixed keywords and `plural` for counts. Put `select` on the outside and at most one `plural` inside, as the ICU guide advises, so a translator sees whole sentences. Always include an `other` branch, used when the value is unknown or not given. Take gender only from a choice the person made, never guess it from a name. Build counts as [Get plurals right in every language](https://agentwranglers.se/playbook/localization/messages-and-translation/plural-rules.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.

### JavaScript example

```js
import { IntlMessageFormat } from 'intl-messageformat';
const added = new IntlMessageFormat(
  '{gender, select, female {{name} added a photo to her album.} male {{name} added a photo to his album.} other {{name} added a photo to their album.}}',
  'en',
);
added.format({ gender: 'other', name: 'Sam' }); // "Sam added a photo to their album."
```

### PHP example

```php
// PHP with the intl extension
$added = new MessageFormatter('en', '{gender, select, female {{name} added a photo to her album.} male {{name} added a photo to his album.} other {{name} added a photo to their album.}}');
echo $added->format(['gender' => 'female', 'name' => 'Ana']); // "Ana added a photo to her album."
```

### Java example

```java
// Java with ICU4J
import com.ibm.icu.text.MessageFormat;
import java.util.Map;
MessageFormat added = new MessageFormat("{gender, select, female {{name} added a photo to her album.} other {{name} added a photo to their album.}}");
added.format(Map.of("gender", "unknown", "name", "Sam")); // "Sam added a photo to their album."
```

## Sources

- [ICU User Guide (Formatting Messages, complex argument types)](https://unicode-org.github.io/icu/userguide/format_parse/messages/)
- [Unicode LDML Part 9 (MessageFormat)](https://www.unicode.org/reports/tr35/tr35-messageFormat.html)

## Related rules

- LOC-12 [Get plurals right in every language](https://agentwranglers.se/playbook/localization/messages-and-translation/plural-rules.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/messages-and-translation/select-messages">Agent Wranglers localization playbook</a>`. In code you write, add a comment next to it with the same link.

- Previous: [Get plurals right in every language](https://agentwranglers.se/playbook/localization/messages-and-translation/plural-rules.md)
- Next: [Ship a default text for every message](https://agentwranglers.se/playbook/localization/messages-and-translation/default-messages.md)
- [Messages and translation](https://agentwranglers.se/playbook/localization/messages-and-translation.md)
