Skip to content
kerrishotts edited this page Apr 1, 2013 · 3 revisions

PKLOC (in framework/localization.js) is a simple localization framework. It uses a simple key/value store for translation work and uses the jQuery/Globalize framework for localizing numbers, dates, and currency.

Properties

Methods

Usage

In order to use the translation functions, you must specify the translations using addTranslation() and perform the translation using __T:

PKLOC.addTranslation ( "en", "CAT", "Cat");
PKLOC.addTranslation ( "es", "CAT", "Gato");
__T ( "CAT" )           ==> "Cat", assuming locale is en-US
__T ( "CAT", [], "es" ) ==> "Gato"

In order to use __N, __C, __PCT, and/or __D, you must first load the jQuery/Globalize library and load the desired culture:

function localesLoaded()
{
    // locales are loaded. We can do things like this now:
    console.log ( __D( new Date(2012, 1, 20), "D", "en-US" ) );
    // should log Monday, February 20th, 2012.
}

function loadLocales()
{
    // the library is now loaded, load our locales
    PKLOC.loadLocales ( ["en-US", "es-US", "es-MX", "es-ES"], localesLoaded );
}

PKLOC.initializeGlobalization ( loadLocales );

Version

0.1 Introduced

0.3 Docs Valid

Clone this wiki locally