Going Global with JavaScript and Globalize.js

Going Global with JavaScript and Globalize.js
202 pages
ISBN: 9781618220004


Enterprise PDF: $250
For sharing with web and developer teams; immediate download.


Single User PDF: $20
For individuals; immediate download.


Also available from:

For discounts on bulk print orders, please contact us.
A hands-on guide for taking JavaScript applications global

Code samples
Book excerpt (1.8MB)
How to localize date formats using Globalize.js

As developers expand JavaScript applications to serve users around the world, problems typically arise regarding the best way to handle new languages, locales, dates, and measurements.

This book is designed to help. Going Global with JavaScript and Globalize.js is unique in its focus on globalization, internationalization, and localization issues.

The books helps make JavaScript applications world-ready and easily adapted to different human languages, notational conventions, and user interface preferences. The solutions and methods included range from simple programming constructs to elaborate techniques that use available information for hundreds of human languages, such as the Common Locale Data Repository (CLDR).

There is a special focus on the emerging Globalize.js library, which provides data sets for more than 300 cultures, as well as the ability to develop custom cultures.

The techniques included in this book, which are not readily found elsewhere, are easy to learn and apply.

Who should read this book

This book is written for web and software developers, as well as program managers and designers. While knowledge of JavaScript is preferred, readers who simply want to understand the JavaScript locale concept and its limitations will find this book valuable.

If you're developing JavaScript applications for use in different languages and countries, this book will help you avoid potentially costly and time-consuming mistakes. More important, this book will help you make the most of existing JavaScript libraries so you can more efficiently develop global applications.

Readers of this book will learn

  • How to ensure an application is "world ready"—removing unnecessary language and culture dependencies
  • How to adapt a JavaScript app to local conventions, such as date formats, systems of measurement, time zones, and more
  • How to leverage the Common Locale Data Repository (CLDR) to support global applications
  • How to localize the user interface to address different cultural requirements and expectations
  • How to handle text input that falls well outside traditional "A-Z" characters
  • How to properly test and validate JavaScript apps for world-readiness

Table of Contents

  • Introduction
  • Part I: Globalization, Localization and JavaScript
    • Globalization and JavaScript
    • Hands-on: JavaScript and Dates
    • HTML and Emerging Opportunities (and Challenges)
    • Localization and Libraries
      • Localization scope: Which features should we localize?
      • Localization scale: From specific to universal
      • Localization on the server-side vs. client-side
      • Using libraries
      • Identifying locales
      • The Common Locale Data Repository (CLDR)
  • Part II: Going Global with Globalize
    • Using the Globalize Framework
      • What is Globalize?
      • Installing Globalize
      • The Globalize approach
      • Selecting a locale
    • Hands-on with Globalize: Formatting Dates and Times
      • Formatting codes recognized by Globalize.format
      • Notes on formatting codes
      • 12 h vs. 24 h time
      • Localizing for time zone
      • The neutral ISO 8601 notation
      • Date and time in four formats
      • The Internet date format
      • Cultural relativity in dates
      • Notations and calendars
      • Cultures with multiple calendars
      • Date format as a personal preference
      • Summary of culture objects in Globalize
      • Generating “Last modified” information
      • Reading dates
      • Coding it yourself
    • Hands-on with Globalize: Numbers
      • The problems with formatting numbers
      • Using Globalize
      • Exponential notation
      • Using a real minus
      • Ordinal numbers
      • Special values and errors
      • Localized number systems
    • Advanced Use of Globalize
      • Parsing data with Globalize
      • String localization in Globalize
      • Modifying and adding locales
      • Setting up a generic localizer function
      • Example: A localized input form
      • The new <input> elements in HTML5
  • Part III: Managing Languages, Cultures and Characters
    • Making It Globalization Ready
    • Translating Strings Successfully
    • Identifying Languages
    • Managing Languages
      • Deducing the language of a web page
      • Deducing the language of an element
      • Passing language parameters to web pages
      • Changing the language of an element
      • Size requirements
      • Hyphenation and word division
      • Directionality
    • Punctuation Marks
    • Programmatic Generation of Text
      • The problem with plurals
      • From localization by pattern to localized patterns
    • Embedding Machine Translation
    • Typography
    • Adapting to Local and Cultural Conventions
      • Monetary values
      • Physical quantities
      • Telephone numbers
      • Other identifying numbers
      • Personal names
      • Postal addresses
      • Graphic symbols
      • Colors
      • List notations
    • User-driven Adaptations
      • Geolocation
      • Accessibility
      • Personal preferences
    • Managing Characters and Strings
      • Legacy encodings
      • Unicode
      • Character escapes
      • Character input
      • Supporting native characters vs. falling back to ASCII
      • Rejecting what you cannot handle
      • Regular expressions: The ASCII legacy
      • Using Unicode character properties
      • Understanding the string type
      • BMP, the “16-bit subrange,” and beyond
      • Private use characters
      • Sanity checks
      • String comparisons and sorting
      • Case conversions
      • Normalization
    • Error Handling and Testing
      • Minimizing error messages
      • Always check return values
      • Using try and9 catch
      • Testing localization
  • Appendix: Localizing Identifiers

Download book excerpt (1.8MB)


About the Author

Jukka K. Korpela is a world-renowned expert on localization, character codes, orthography, usability, and accessibility. He is author of Unicode Explained (O'Reilly, 2006).

Learn more