Home Reference Source
import Localizer from 'potassium-es/src/Localizer.js'
public class | source

Localizer

Extends:

EventHandler → Localizer

Localizer provides the functionality necessary to:

  • pick a string translation based on language
  • format dates based on locale and time zone

TODO:

  • detect language, locale, and timezone
  • load translations

Static Member Summary

Static Public Members
public static get

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public get

Different locales order their dates in various ways: mm/dd/yyyy or yyyy.mm.dd or 2012년 12월 20일 목요일

public get
public get
public get

gatheredData: {"strings": *}

public get

This should NOT be turned on in production because it continuously grows in memory.

public set
public get

Method Summary

Public Methods
public

formatDate(date: *, long: boolean, options: undefined): *

public

formatDateObject(date: *, options: *): *

public

formatDateTime(date: *, long: boolean, options: undefined): *

public

translate(key: *, defaultValue: undefined): *

Inherited Summary

From class EventHandler
public get

listeners: EventListener[]: *

public

addListener(callback: function(eventName: string, eventSource: EventHandler), eventName: Object | Symbol, once: bool)

public
public

removeListener(callback: *, eventName: undefined)

public

trigger(eventName: *, params: ...*)

Send an event to listeners

Static Public Members

public static get Singleton: * source

Public Constructors

public constructor() source

Public Members

public get dateFieldOrder: string[]: * source

Different locales order their dates in various ways: mm/dd/yyyy or yyyy.mm.dd or 2012년 12월 20일 목요일

Return:

string[]

a length 3 array of 'day', 'month', and 'year' in the order that this locale renders date fields

public get defaultLocales: * source

public get defaultTimeZone: * source

public get gatheredData: {"strings": *} source

public get gathering: boolean: * source

This should NOT be turned on in production because it continuously grows in memory.

Return:

boolean

true if the Localizer is accumulating strings to translate

public set gathering source

public get monthNames: * source

Public Methods

public formatDate(date: *, long: boolean, options: undefined): * source

Params:

NameTypeAttributeDescription
date *
long boolean
  • optional
  • default: false
options undefined
  • optional
  • default: undefined

Return:

*

public formatDateObject(date: *, options: *): * source

Params:

NameTypeAttributeDescription
date *
options *

Return:

*

public formatDateTime(date: *, long: boolean, options: undefined): * source

Params:

NameTypeAttributeDescription
date *
long boolean
  • optional
  • default: false
options undefined
  • optional
  • default: undefined

Return:

*

public translate(key: *, defaultValue: undefined): * source

Params:

NameTypeAttributeDescription
key *
defaultValue undefined
  • optional
  • default: undefined

Return:

*