Book Image

JavaScript at Scale

By : Adam Boduch
Book Image

JavaScript at Scale

By: Adam Boduch

Overview of this book

Table of Contents (17 chapters)
JavaScript at Scale
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Setting the locale


Once we have our internationalization library in place, and a couple of locales, we can start testing how our application behaves from the perspective of different cultures. There are a number of items to consider for this behavior. For example, we need to facilitate the locale selection for the user and we need to keep track of that selection.

Choosing locales

There are two common approaches to locale selection in JavaScript applications. The first approach is using the accept-language request header. The second approach is a selector widget on a user settings page.

The nice thing about the accept-language approach is that there's no user input involved. Our application is sent to the user's browser preference for language, and from there, we can set the locale. The challenge is that this approach can be too restrictive from a usability perspective, and from an implementation perspective. For example, users may not have control over their browser language preferences, or...