---
title: "Format lists and durations with locale · Agent Wranglers"
url: https://agentwranglers.se/playbook/localization/formatting/list-and-duration-formats
id: LOC-51
level: Optional
updated: 2026-10-22
build: a2a6bdfed830
tokens: 732
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Format lists and durations with locale data

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

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

- ID: LOC-51
- Level: Optional
- Chapter: [Formatting](https://agentwranglers.se/playbook/localization/formatting.md)
- Rule: Join visible lists with a locale list formatter and format durations with a locale duration formatter. Never join with a hard-coded comma and "and".
- Check: A unit test formats `["A", "B", "C"]` in `en`, `es` and `ja` and gets `A, B, and C`, `A, B y C` and `A、B、C`. A search finds no `join(', ')` on visible text.
- How: "A, B and C" becomes "A, B y C" in Spanish and "A、B、C" in Japanese. Durations such as "1 hr, 5 min" change words and order too. Use `Intl.ListFormat` and `Intl.DurationFormat` in JavaScript, or Babel's `format_list` and `format_timedelta` in Python. Keep the formatted list inside one message, as [Translate whole sentences](https://agentwranglers.se/playbook/localization/messages-and-translation/whole-sentence-messages.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
new Intl.ListFormat('es', { type: 'conjunction' }).format(['A', 'B', 'C']); // 'A, B y C'
new Intl.DurationFormat('sv', { style: 'short' }).format({ hours: 1, minutes: 5 });
```

### Python example

```python
from datetime import timedelta
from babel.dates import format_timedelta
from babel.lists import format_list

format_list(["A", "B", "C"], locale="es")  # 'A, B y C'
format_timedelta(timedelta(minutes=65), locale="sv")
```

## Sources

- [ECMA-402 (Intl.ListFormat and Intl.DurationFormat)](https://tc39.es/ecma402/)

## Related rules

- LOC-13 [Translate whole sentences](https://agentwranglers.se/playbook/localization/messages-and-translation/whole-sentence-messages.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/formatting/list-and-duration-formats">Agent Wranglers localization playbook</a>`. In code you write, add a comment next to it with the same link.

- Previous: [Read the week start and units from locale data](https://agentwranglers.se/playbook/localization/formatting/week-and-units-from-cldr.md)
- Next: [Show and accept phone numbers in each country's format](https://agentwranglers.se/playbook/localization/formatting/phone-number-formats.md)
- [Formatting](https://agentwranglers.se/playbook/localization/formatting.md)
