new Translate(options)
Class for language translation using the Google Translate Gadget
Parameters:
| Name | Type | Description |
|---|---|---|
options |
nyc.lang.Translate.Options | Constructor options |
- Source:
Fires:
- nyc.lang.Translate.EventType#event:ready
- nyc.lang.Translate.EventType#event:change
Extends
Members
(static) EventType :string
Enumeration for nyc.lang.Translate event types
Type:
- string
Properties:
| Name | Type | Description |
|---|---|---|
READY |
string | The ready event type |
CHANGE |
string | The change event type |
- Source:
Methods
getCookieValue() → {string}
- Source:
Returns:
- Type
- string
lang() → {string}
Get the currently chosen language code
- Source:
Returns:
The currently chosen language code
- Type
- string
off(eventName, evtHdlr, hdlrScopeopt)
Remove a previously connected event handler
Parameters:
| Name | Type | Attributes | 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:
- Source:
on(eventName, evtHdlr, hdlrScopeopt)
Connect a function to an event
Parameters:
| Name | Type | Attributes | 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:
- Source:
one(eventName, evtHdlr, hdlrScopeopt)
Connect a function to an event for a single invocation
Parameters:
| Name | Type | Attributes | 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:
- Source:
render()
- Source:
translate()
Sets the chosen language and performs message substitution
- Source:
trigger(eventName, dataopt)
Trigger a named event with event data
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
eventName |
string | The name of the event to trigger | |
data |
Object |
<optional> |
The event data |
- Inherited From:
- Source:
Type Definitions
Choice
A language choice for nyc.lang.Translate.Choices
Type:
- Object
Properties:
| Name | Type | Attributes | Description |
|---|---|---|---|
val |
string | The language value used by Google | |
desc |
string | The display value for the language | |
hint |
string |
<optional> |
The translation of the word 'Translate' in the language |
- Source:
Choices
A mapping of nyc.lang.Translate.Choice objects to language codes
Type:
- Object.<string, nyc.lang.Translate.Choice>
- Source:
Options
Constructor for nyc.lang.Translate
Type:
- Object
Properties:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
target |
String | Element | JQuery | The HTML DOM element that will provide language choices | ||
languages |
nyc.lang.Translate.Choices | The languages to provide | ||
messages |
Object | The language-specific message bundles | ||
defaultLanguage |
string |
<optional> |
'en' | The default language |
isButton |
boolean |
<optional> |
false | Show as a button |
isArrow |
boolean |
<optional> |
false | Show the hint arrow if displaying as a button |
- Source:
Events
change
The language value has changed
Type:
- string
- Source:
ready
The class has completed initialization
Type:
- boolean
- Source: