-
Notifications
You must be signed in to change notification settings - Fork 29
PKLOC
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.
- initializeGlobalization (completion)
- loadLocales (theLocales, completion)
- setGlobalizationLocale (theLocale)
- addTranslation (locale, key, value)
- getUserLocale
- substituteVariables (theString, theParms)
- lookupTranslation (key, theLocale)
- __T (key, parms, locale)
- __N (theNumber, theFormat, theLocale)
- __C (theNumber, theFormat, theLocale)
- __PCT (theNumber, theFormat, theLocale)
- __D (theDate, theFormat, theLocale)
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 );
0.1 Introduced
0.3 Docs Valid