new Translate(options)
Create an instance of Translate
Parameters:
Name | Type | Description |
---|---|---|
options |
module:nyc/lang/Translate~Translate.Options | Constructor options |
- Source:
Fires:
Extends
Members
-
<static, constant> DEFAULT_LANGUAGES :module:nyc/lang/Translate~Translate.Choices
-
Default languages for NYC
Type:
- Source:
Methods
-
append(elements)
-
A method to append elements to the container
Parameters:
Name Type Description elements
jQuery | Element | Array.<Element> | string The element to append
- Inherited From:
- Overrides:
- Source:
Returns:
The container
- Type
- jQuery
-
find(selector)
-
A method to return elements in the container
Parameters:
Name Type Description selector
string jQuery selector
- Inherited From:
- Overrides:
- Source:
Returns:
The element
- Type
- jQuery
-
getContainer()
-
A method to return a control container HTML element wrapped in a JQuery
- Inherited From:
- Overrides:
- Source:
Returns:
The the control container HTML element wrapped in a JQuery
- Type
- jQuery
-
<protected> getCookieValue()
-
Gets a cookie value
- Source:
Returns:
cookie
- Type
- string
-
lang()
-
Get the currently chosen language code
- Source:
Returns:
The currently chosen language code
- Type
- string
-
off(eventName, evtHdlr [, hdlrScope])
-
Remove a previously connected event handler
Parameters:
Name Type Argument Description eventName
string The name of the event to which the handler will be connected
evtHdlr
function The event handler function
hdlrScope
Object <optional>
The scope in which to invoke the event handler
- Inherited From:
- Overrides:
- Source:
-
on(eventName, evtHdlr [, hdlrScope])
-
Connect a function to an event
Parameters:
Name Type Argument Description eventName
string The name of the event to which the handler will be connected
evtHdlr
function The event handler function
hdlrScope
Object <optional>
The scope in which to invoke the event handler
- Inherited From:
- Overrides:
- Source:
-
one(eventName, evtHdlr [, hdlrScope])
-
Connect a function to an event for a single invocation
Parameters:
Name Type Argument Description eventName
string The name of the event to which the handler will be connected
evtHdlr
function The event handler function
hdlrScope
Object <optional>
The scope in which to invoke the event handler
- Inherited From:
- Overrides:
- Source:
-
prepend(elements)
-
A method to prepend elements to the container
Parameters:
Name Type Description elements
jQuery | Element | Array.<Element> | string The element to append
- Inherited From:
- Overrides:
- Source:
Returns:
The container
- Type
- jQuery
-
translate(event)
-
Sets the chosen language and performs message substitution
Parameters:
Name Type Description event
jQuery.Event Event object
- Source:
-
trigger(eventName [, data])
-
Trigger a named event with event data
Parameters:
Name Type Argument Description eventName
string The name of the event to trigger
data
Object <optional>
The event data
- Inherited From:
- Overrides:
- Source:
Type Definitions
-
Choice
-
A language choice for module:nyc/lang/Translate~Translate.Choices
Type:
- Object
- Source:
Properties:
Name Type Argument Description code
string The language code
name
string The language name
native
string The display value for the language
hint
string <optional>
The translation of the word 'Translate' in the language
-
Choices
-
A mapping of module:nyc/lang/Translate~Translate.Choice objects to language codes
Type:
- Object.<string, module:nyc/lang/Translate~Translate.Choice>
- Source:
-
Options
-
Constructor options for module:nyc/lang/Translate~Translate
Type:
- Object
- Source:
Properties:
Name Type Argument Default Description target
String | Element | JQuery The DOM element that will provide language choices
languages
Translate.Choices The languages to provide
messages
Object.<string, Object.<string, string>> The language-specific message bundles
defaultLanguage
string <optional>
'en' The default language
button
boolean <optional>
false Show as a button
Events
-
change
-
The language value has changed
Type: string
- Source:
-
ready
-
The class has completed initialization
Type: boolean
- Source: