Class: Translate

nyc/lang/Translate~ Translate


new Translate(options)

Class for language translation using the Google Translate Gadget

Parameters:
Name Type Description
options module:nyc/lang/Translate~Translate.Options

Constructor options

Source:
Fires:

Extends

  • module:nyc/lang/Container~Container

Members


<static, constant> DEFAULT_LANGUAGES :module:nyc/lang/Translate~Translate.Choices

Default languages for NYC

Type:
Source:

Methods


<protected> getCookieValue()

Gets a cookie value

Source:
Returns:
Type
string

lang()

Get the currently chosen language code

Source:
Returns:

The currently chosen language code

Type
string

translate(event)

Sets the chosen language and performs message substitution

Parameters:
Name Type Description
event jQuery.Event
Source:

Type Definitions


Choice

Type:
  • Object
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

Source:

Choices

A mapping of Translate.Choice objects to language codes

Type:
Source:

Options

Constructor options for module:nyc/lang/Translate~Translate

Type:
  • Object
Properties:
Name Type Argument Default Description
target String | Element | JQuery

The HTML 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

Source:

Events


change

The language value has changed

Type: string
Source:

ready

The class has completed initialization

Type: boolean
Source: