A small structural-only zero-dependency Web Component to show Parity Purchasing Power normalized prices. Inspired by the Wes Bos blog post.
Return to the source code on GitHub.
Please note that this is not a currency converter (you will get the same currency out that you put in). It transforms the number value with a parity purchasing ratio to normalize that cost to a new price for a specified country. Outputs use the Intl.NumberFormat
API to properly format localized currency values.
This (optionally) works with CloudCannonβs Geolocation feature to automatically detect the visitorβs country.
Implicit Currency
Currency is parsed from three letter code in text content. Read more about currency-display
options.
From | Input | To | Output | Note |
---|---|---|---|---|
US πΊπΈ | USD $10 | GB π¬π§ | ||
FR π«π· | EUR 10 β¬ | DE π©πͺ | ||
FR π«π· | EUR 20 β¬ | DE π©πͺ | ||
FR π«π· | EUR 100 β¬ | DE π©πͺ | ||
US πΊπΈ | USD $100 | UY πΊπΎ | ||
US πΊπΈ | USD $10 | GB π¬π§ | Extra text is stripped. | |
GB π¬π§ | GBP Β£10 | US πΊπΈ | ||
US πΊπΈ | $10 USD | GB π¬π§ | Input value has currency as a suffix | |
US πΊπΈ | $4.00 USD | GB π¬π§ | With currency-display="code" |
Explicit Currency
Currency code is specified in currency
attribute. Read more about currency-display
options.
From | Input | To | Output | Note |
---|---|---|---|---|
GB π¬π§ | Β£10 | US πΊπΈ | With currency="GBP" |
|
GB π¬π§ | Β£10 | US πΊπΈ | With currency="GBP" currency-display="code" |
|
CA π¨π¦ | $4.00 | NZ π³πΏ | With currency="CAD" |
|
CA π¨π¦ | $4.00 | NZ π³πΏ | With currency="CAD" currency-display="code" |
Using Geolocation
(Optional) The country code is provided for the visitor automatically using CloudCannonβs Geolocation feature.
From | Input | To | Output | Note |
---|---|---|---|---|
GB π¬π§ | GBP Β£6.77 | Implicit | ||
CA π¨π¦ | 4.00 | Implicit, with currency="CAD" |
||
FR π«π· | EUR 4 β¬ | Implicit | ||
DE π©πͺ | EUR 4 β¬ | Implicit | ||
US πΊπΈ | USD $4.00 | Implicit | ||
US πΊπΈ | USD $4.00 | With explicit to="auto" |