API Docs for: 1.7.0
Show:

photonui.Translation Class

Extends photonui.Base
Module: NonVisual
Parent Module: PhotonUI

A wrapper around Stone.js to fire locale events to widgets.

Documentation: https://github.com/flozz/stone.js/blob/master/README.md

NOTE: When you instantiate the translation widget, you can pass to it the noGlobal option to avoid the creation of the global window._ function.

wEvents:

  • locale-changed:
    • description: The locale changed.
    • callback: function(widget, locale)

Constructor

photonui.Translation

(
  • params
)

Parameters:

  • params Object

    An object that can contain any property of the widget (optional).

Methods

__onStonejsLocaleChanged

() private

_bindEvent

(
  • id
  • element
  • evName
  • callback
)
private

Inherited from photonui.Base: src/base.js:229

Javascript event binding (for internal use).

Parameters:

  • id String
    An unique id for the event.
  • element DOMElement
    The element on which the event will be bind.
  • evName String
    The event name (e.g. "mousemove", "click",...).
  • callback Function
    The function that will be called when the event occured.

_callCallbacks

(
  • wEvent
  • params
)
private

Inherited from photonui.Base: src/base.js:288

Call all callbacks for the given wEvent. NOTE: the first argument passed to the callback is the current widget. NOTEĀ²: if the thisArg of the callback is null, this will be binded to the current widget.

Parameters:

  • wEvent String
    The widget event.
  • params Array
    Parametters that will be sent to the callbacks.

_registerWEvents

(
  • wEvents
)
private

Inherited from photonui.Base: src/base.js:272

Register available wEvent.

Parameters:

_unbindEvent

(
  • id
)
private

Inherited from photonui.Base: src/base.js:253

Unbind javascript event.

Parameters:

  • id String
    The id of the event.

_updateProperties

(
  • properties
)
deprecated private

Inherited from photonui.Base: src/base.js:209

Force the update of the given properties. This method is deprecated. One should use '@photonui-update' abitbol's annotation on concerned properties.

Parameters:

  • properties Array
    The properties to update.

addCatalogs

(
  • catalogs
)

Add one or more Stone.js catalog (a catalog contain all translated strings for a specific locale).

Parameters:

destroy

()

Inherited from photonui.Base: src/base.js:157

Destroy the class.

enableDomScan

(
  • boolean
)

Enable/disable Stone.js translating elements with the "stonejs" attribute in the DOM.

Parameters:

  • boolean Boolean

    Enable or disable DOM scanning.

gettext

(
  • string
  • replacements
)
String

Make a string translatable.

Parameters:

  • string String

    the Translatable string

  • replacements Object

    An object that contain replacements for the string.

Returns:

guessUserLanguage

() String

Guess the user language.

Returns:

String:

The language code (e.g. "en", "fr", "it",...)

lazyGettext

(
  • string
  • replacements
)
LazyString

Make a string translatable.

The main difference between this method and the gettext method is that this method does not return a translated sting but an object that will translate the sting when it will be displayed (.toString() method called).

Parameters:

  • string String

    the Translatable string

  • replacements Object

    An object that contain replacements for the string.

Returns:

LazyString:

registerCallback

(
  • id
  • wEvent
  • callback
  • thisArg
)

Inherited from photonui.Base: src/base.js:169

Register a callback for any PhotonUI/Widget event (called wEvent). Callback signature: function (Object(Base/Widget) [, arg1 [, arg2 [, ...]]])

Parameters:

  • id String
    An unique id for the callback.
  • wEvent String
    the PhotonUI/Widget event name.
  • callback Function
    The callback function.
  • thisArg Object
    The value of this (optionnal, default = current widget).

removeCallback

(
  • id
)

Inherited from photonui.Base: src/base.js:193

Remove a registered callback.

Parameters:

  • id String
    The id of the callback.

setBestMatchingLocale

(
  • locales
)

Find and set the best language for the user (depending on available catalogs and given language list).

Parameters:

  • locales Array | String

    Language list (optional, e.g. "fr", ["fr", "fr_FR", "en_US"]).

updateDomTranslation

()

Re-translate elements with the "stonejs" attribute in the DOM.

Properties

__callbacks

Object private

Inherited from photonui.Base: src/base.js:142

Object containing references to registered callbacks.

__events

Object private

Inherited from photonui.Base: src/base.js:132

Object containing references javascript events binding (for widget internal use).

data

Object

Inherited from photonui.Base: src/base.js:113

Arbitrary data

Default: {}

locale

String

The current locale (e.g. "fr", "en", "it",...).

Default: null