@hydroperx/pi / / PI
Defined in: src/index.ts:10
PI stands for product internationalization.
PI manages Project Fluent translation lists (FTL) and translates
messages.
EventTarget
new PI(
params):PI
Defined in: src/index.ts:47
PI
EventTarget.constructor
get currentLocale():
Locale|null
Defined in: src/index.ts:138
Returns the currently loaded locale or null if none.
Locale | null
get fallbacks():
Locale[]
Defined in: src/index.ts:157
Returns the currently loaded fallbacks.
Locale[]
get localeAndFallbacks():
Locale[]
Defined in: src/index.ts:145
Returns the currently loaded locale followed by its fallbacks or empty if no locale is loaded.
Locale[]
get locales():
Set<Locale>
Defined in: src/index.ts:118
Returns a set of supported locales, reflecting
the ones that were specified when constructing the PI object.
Set<Locale>
get status():
PIStatus
Defined in: src/index.ts:170
Returns the status of the PI instance
(e.g., "ok", "loading" or "error").
addBundleInitializer(
fn):void
Defined in: src/index.ts:110
Adds a bundle initializer. This allows defining custom functions and more.
void
addEventListener(
type,callback,options?):void
Defined in: node_modules/typescript/lib/lib.dom.d.ts:8303
Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched.
The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture.
When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT_TARGET.
When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in § 2.8 Observing event listeners.
When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed.
If an AbortSignal is passed for options's signal, then the event listener will be removed when signal is aborted.
The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture.
string
EventListenerOrEventListenerObject | null
boolean | AddEventListenerOptions
void
EventTarget.addEventListener
clone():
PI
Defined in: src/index.ts:388
Clones the PI object, but returning an object that is
in sync with the original PI object.
PI
dispatchEvent(
event):boolean
Defined in: node_modules/typescript/lib/lib.dom.d.ts:8309
Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.
Event
boolean
EventTarget.dispatchEvent
get(
id,args,errors):string|null
Defined in: src/index.ts:272
Retrieves message and formats it. Returns null if undefined.
Look at @fluent/bundle
for FluentVariable.
string
Record<string, FluentVariable> | undefined
Error[] | null
string | null
has(
id):boolean
Defined in: src/index.ts:325
Determines if a message is defined.
string
boolean
load(
newLocale):Promise<boolean>
Defined in: src/index.ts:186
Attempts to load a locale and its fallbacks. If the locale argument is specified, it is loaded. Otherwise, if there is a default locale, it is loaded, and if not, the method throws an error.
If any resource fails to load, the returned Promise
resolves to false, otherwise true.
Also dispatches either the load or error event,
when loading is completed.
Locale | null
Promise<boolean>
off<
T>(type,listener,params?):void
Defined in: src/index.ts:373
Shortcut for the removeEventListener() method.
T extends keyof PIEventMap
T
(event) => void
boolean | EventListenerOptions
void
off(
type,listener,params?):void
Defined in: src/index.ts:378
Shortcut for the removeEventListener() method.
string
Function
boolean | EventListenerOptions
void
on<
T>(type,listener,params?):void
Defined in: src/index.ts:359
Shortcut for the addEventListener() method.
T extends keyof PIEventMap
T
(event) => void
boolean | AddEventListenerOptions
void
on(
type,listener,params?):void
Defined in: src/index.ts:364
Shortcut for the addEventListener() method.
string
Function
boolean | AddEventListenerOptions
void
removeEventListener(
type,callback,options?):void
Defined in: node_modules/typescript/lib/lib.dom.d.ts:8315
Removes the event listener in target's event listener list with the same type, callback, and options.
string
EventListenerOrEventListenerObject | null
boolean | EventListenerOptions
void
EventTarget.removeEventListener
supportsLocale(
argument):boolean
Defined in: src/index.ts:131
Returns true if the locale is one of the supported locales
that were specified when constructing the PI object,
otherwise false.
string | Locale
boolean