---
title: "Take the currency from the amount and not · Agent Wranglers"
url: https://agentwranglers.se/playbook/localization/formatting/currency-from-the-amount
id: LOC-27
level: Required
applies: payments
risk: money
updated: 2026-10-22
build: a2a6bdfed830
tokens: 1004
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Take the currency from the amount and not from the locale

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-27
- Level: Required
- Chapter: [Formatting](https://agentwranglers.se/playbook/localization/formatting.md)
- Rule: Format every price with the currency code stored with that amount. The reader's locale chooses only the separators and the symbol position.
- Check: A test renders the cart, the checkout and the receipt for a SEK order in the `en-US`, `de-DE` and `ja-JP` locales. Every amount shows SEK and the charged number. A search finds no currency formatter call without an explicit currency.
- Risk: Money lost or taken twice
- Applies when: The project takes payments.
- How: A Swede browsing in English must still see the 129 SEK you will charge, not $129. Keep each amount and its ISO 4217 code together, as [Hold money as integer minor units everywhere](https://agentwranglers.se/playbook/payments/amounts-and-orders/money-in-minor-units.md) says. Pass that code to the formatter every time. Never read a default currency from the locale or the browser. Convert minor units with the currency's own number of decimals, as [money](https://agentwranglers.se/playbook/api-design/requests-and-responses/money.md) explains. Prices in several currencies follow [Set a price in each currency](https://agentwranglers.se/playbook/payments/currencies-and-settlement/price-per-currency.md).

## 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
const MINOR_UNITS = { SEK: 2, JPY: 0, EUR: 2 };
export function formatPrice({ amountMinor, currency }, locale) {
  const amount = amountMinor / 10 ** MINOR_UNITS[currency];
  return new Intl.NumberFormat(locale, { style: 'currency', currency }).format(amount);
}
formatPrice({ amountMinor: 12900, currency: 'SEK' }, 'en-US'); // "SEK 129.00"
```

### Python example

```python
from decimal import Decimal
from babel.numbers import format_currency, get_currency_precision

def format_price(amount_minor: int, currency: str, locale: str) -> str:
    amount = Decimal(amount_minor).scaleb(-get_currency_precision(currency))
    return format_currency(amount, currency, locale=locale)

format_price(12900, "SEK", "de_DE")  # "129,00 SEK"
```

## Sources

- [ECMA-402 (NumberFormat objects, currency option)](https://tc39.es/ecma402/#numberformat-objects)

## Related rules

- PAY-10 [Hold money as integer minor units everywhere](https://agentwranglers.se/playbook/payments/amounts-and-orders/money-in-minor-units.md) in Payments and billing
- API-8 [Send money as an integer with its currency](https://agentwranglers.se/playbook/api-design/requests-and-responses/money.md) in API design
- PAY-66 [Set a price in each currency instead of converting at checkout](https://agentwranglers.se/playbook/payments/currencies-and-settlement/price-per-currency.md) in Payments and billing

**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/currency-from-the-amount">Agent Wranglers localization playbook</a>`. In code you write, add a comment next to it with the same link.

- Previous: [Writing date formats by hand](https://agentwranglers.se/playbook/localization/formatting/hand-written-date-patterns.md)
- Next: [Read the week start and units from locale data](https://agentwranglers.se/playbook/localization/formatting/week-and-units-from-cldr.md)
- [Formatting](https://agentwranglers.se/playbook/localization/formatting.md)
