Skip to content

Conversation

@xfq
Copy link
Member

@xfq xfq commented Jun 19, 2025

Fix #410. Comments welcome.

Preview

@xfq xfq requested review from aphillips and r12a June 19, 2025 02:41
@netlify
Copy link

netlify bot commented Jun 19, 2025

Deploy Preview for i18n-drafts ready!

Name Link
🔨 Latest commit 47b340f
🔍 Latest deploy log https://app.netlify.com/projects/i18n-drafts/deploys/68ec954ea4fe900008a21ddb
😎 Deploy Preview https://deploy-preview-693--i18n-drafts.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.


Many regions, like the US and UK, use a period as the decimal separator (e.g., `1,234.56`). Conversely, much of Europe and South America use a comma (e.g., `1.234,56`).

In rare cases, a currency symbol can even act as a decimal separator, like the [Cape Verdean escudo](https://en.wikipedia.org/wiki/Cape_Verdean_escudo).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add an example here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The double barrd dollarsign doesn't seem to be encoded in Unicode. Should I use a picture to represent it?


**Symbol vs. Code vs. Name:** Currencies can be displayed using a specific symbol (e.g., ``, `£`, `¥`), their ISO 4217 code (e.g., `EUR`, `GBP`, `JPY`), or their full name (e.g., `US Dollar`, `Japanese Yen`).

**Placement:** The symbol can appear before the number (e.g., `$100.00`) or after (e.g., `1,000 ₫`).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example illustrates that white space also varies.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added.


## By the way

Typically, you'll want to format based on the user's browser language. You can get this from `navigator.language` or `navigator.languages`:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, this probably merits its own section. There may be times when it's best to use the browser settings, but usually its the page language or current section language that is more important.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was going to thumbs-up this comment, but I'd be more emphatic. Typically you want to use the locale (language) of the page. Occasionally you'll want to override that with an author specified locale (such as when writing I18N tutorials). Rarely will you want to peek at browser language (and there is no way to do so at the server--Accept-Language isn't quite the same thing).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. I edited the content of this section.


## Further reading

* [ECMAScript Internationalization API Specification](https://tc39.es/ecma402/) No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add some dos and donts to the Web and point to that, too.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I'm going to add the dos and donts after this article is published so that I can link to it.

Copy link
Contributor

@aphillips aphillips left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partial review.


## Question

**How do I prepare my web pages to display varying international number, currency, and unit formats?**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this is the right question for what this article proceeds to talk about? JS is a mechanism for formatting data into strings dynamically in the page. Some parts of a Web page will need to do that, but this question sounds like it would cover server-side formatting.


I'll also call out that numbers and currencies are a broad topic. Units are complicated and might warrant separate coverage. (Currencies are complicated too, but are generally bundled with numbers. Don't overlook percentages, which are also commonly bundled, but which are a sort of unit.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this is the right question for what this article proceeds to talk about? JS is a mechanism for formatting data into strings dynamically in the page. Some parts of a Web page will need to do that, but this question sounds like it would cover server-side formatting.

What about: How do I use JavaScript to dynamically format numbers, currencies, and units for different locales?


I'll also call out that numbers and currencies are a broad topic. Units are complicated and might warrant separate coverage. (Currencies are complicated too, but are generally bundled with numbers. Don't overlook percentages, which are also commonly bundled, but which are a sort of unit.)

Any specific suggestions? Should we expand this article or start a new one?


#### Currency symbol display

**Symbol vs. Code vs. Name:** Currencies can be displayed using a specific symbol (e.g., ``, `£`, `¥`), their ISO 4217 code (e.g., `EUR`, `GBP`, `JPY`), or their full name (e.g., `US Dollar`, `Japanese Yen`).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the full range. There are also "medium" width symbols used in various contexts, such as CA$, US$ and MX$

There are also contextual variations, e.g. ¥ vs. (in sentences).

Symbols are not always a single code point and you should probably have some examples of those.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough. I expanded this paragraph.


**Placement:** The symbol can appear before the number (e.g., `$100.00`) or after (e.g., `1,000 ₫`).

**Ambiguity:** The same symbol might represent multiple currencies (e.g., `$` for US Dollar, Canadian Dollar, Australian Dollar, etc.). So the locale is crucial.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The locale is crucial all the time. Note that the Mexican peso also uses $ and makes a good example (showing that $ doesn't mean the word dollar is lurking nearby)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Fixed.

Copy link

@jsahleen jsahleen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great article! Mentioned a couple of minor points but nothing blocking.


### Choosing the right locale

Typically, you'll want to format number, currency, and unit according to the language of the web page. This can be determined from the `lang` attribute:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think something about the wording here might lead people to think the lang attribute is populated by default, when it needs to be set. This isn't the right place for an in-depth discussion, I think, but is there an article or guide on choosing the right locale we can point to?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jsahleen if you want an article that's specifically about choosing the right locale you may be looking for https://www.w3.org/International/questions/qa-choosing-language-tags.en.html

Otherwise, there are a bunch of other language setting related articles at https://www.w3.org/International/articlelist#language

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I added a link.

@xfq xfq merged commit a5eafc0 into gh-pages Oct 16, 2025
4 checks passed
@xfq xfq deleted the xfq/issue-410 branch October 16, 2025 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

An article about number, currency, and unit formatting

5 participants