Home > Html - Css - JavaScript > Localization(I10N) and Internationalization(I18N) in JavaScript

Localization(I10N) and Internationalization(I18N) in JavaScript

In recent days I’ve been looking for a plug-in for my JQuery Mobile Application so I can easily and quickly add localization and internationalization. There are several possibilities to do it.

One of them is Globalize,  a JavaScript library for globalization and localization. Enables complex culture-aware number and date parsing and formatting for hundreds of different languages and countries. It has also an extensible system for localization.

Default culture is “en” also English, if you add globalize.js in your project. You can add globalize.culture.de-DE.js for German to change the parsing and formatting settings.

For translation you must expand it a little. For example ;

Globalize.addCultureInfo( "de", {
    messages: {
        "label_settings": "Einstellungen",
        "error_empty_username": "Bitte ein Benutzername eingeben", 
        "error_empty_email": "Bitte ein E-Mail eingeben", 
        "error_empty_password": "Bitte ein Password eingeben"

Globalize.addCultureInfo( "en", {
    messages: {
        "label_settings": "Settings",
        "error_empty_username": "Please enter your username", 
        "error_empty_email": "Please enter your e-mail", 
        "error_empty_password": "Please enter your password"


Information can be retrieved as follows :

console.log( Globalize.localize( "label_settings", "de" ) ); // Einstellungen
console.log( Globalize.localize( "label_settings", "en" ) ); // Settings

// assuming a culture where "," is the group separator
// and "." is the decimal separator
console.log(Globalize.parseInt( "1,234.56" )); // 1234

console.log(Globalize.parseDate( "1/2/2003" )); // Thu Jan 02 2003

console.log(Globalize.format( new Date(1955,10,5), "dddd MMMM d, yyyy" )); // "Saturday November 5, 1955"


  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: