Currency
Parse symbols and codes; convert with your own rates.
Prefer the live demos? Open this section in the interactive docs.
Parse symbols, ISO codes, and slang; format via Intl; convert with rates you supply. lingo never bundles or fetches FX.
import { lingo, quantity, fromMinor, convertCurrency } from "@pascal-app/lingo"
lingo("$5", { currency: "CAD" }).quantity.unit // "CAD"
lingo("3 quid 50").quantity.value // 3.5 (GBP)
quantity(5, "USD").format() // "$5.00"
quantity(5, "USD").toMinor() // 500 (Stripe minor units)
fromMinor(500, "USD").value // 5
// Convert with YOUR rates — lingo never bundles or fetches FX.
convertCurrency(100, "USD", "EUR", {
rates: { base: "USD", rates: { EUR: 0.92 } },
}) // 92Bare $ and cents stay ambiguous (an AMBIGUOUS_UNIT warning) until you pass a currency context. Cross-currency convert() without rates fails with RATE_REQUIRED, never a silent wrong answer. toMinor()/fromMinor() handle Stripe integer minor units (JPY → 0 decimals, KWD → 3).