Dates, numbers and text
Format dates, money and units from locale data, keep the currency with each amount, sort by locale, and change case of identifiers without a locale.
- Required 2
- Recommended 4
- Avoid 1
Required
Take the currency from the amount and not from the locale
LOC-27Format every price with the currency code stored with that amount. The reader's locale chooses only the separators and the symbol position.
Change the case of identifiers without a locale
LOC-29Lower-case and upper-case keys, protocol words, file extensions and identifiers with locale-independent functions. Use locale-aware case only for text shown to people.
Recommended
Format dates and numbers for the reader
LOC-11Format dates, numbers and money for the reader's locale with a formatting library. Show times with a named time zone.
Read the week start and units from locale data
LOC-28Read the first day of the week, the weekend, the 12 or 24 hour clock and the measurement system from CLDR locale data. Never hard-code them.
Sort and compare text by locale
LOC-15Sort and compare visible text with a collator for the reader's locale, and normalise Unicode before comparing or storing it.
Accept names and addresses from every country
LOC-16Let people enter names and addresses as they are written in their country. Never reject letters, word counts or field shapes your own country does not use.
Avoid
Writing date formats by hand
LOC-26Never build a date for people from a hand-written pattern such as
MM/dd/yyyy. Ask the formatter for a style or a skeleton, and let the locale data order the fields.
For agents: this playbook is free to use under CC 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/dates-numbers-and-text">Agent Wranglers localization playbook</a>. In code you write, add a comment next to it with the same link.