Hello World

Locales

All chapters

Part 1 · Foundations

Locales

Chapter 2 12 min read 8 sections

A visitor from Auckland lands on your site. Their browser sends this along with the request:

Accept-Language: en-NZ

You've got two sets of English text, en-US and en-GB. Neither of them matches en-NZ, so a simple lookup comes back empty and your app falls back to its default. In a lot of apps that default is American English, so a New Zealander gets "color", "organize" and dates written month first.

They asked for English, you have English, and you still gave them the wrong one. To fix that, you need to know what a locale is and how to pick the closest one you've got.

Keep reading

The rest of this chapter is for readers of the book

Get the book to read the rest of this chapter and every other one, the field guide and the glossary, and to download the whole book as a PDF.

Still to come in this chapter

  • A locale is more than a language
  • Language tags
  • Reading what the user asked for
  • Fallback chains
  • One country, many languages
  • Saying which language you sent back
  • Checklist
  • Further reading