# jsTree v.1.0

# languages plugin

## Description

The `languages` plugin enables multilanguage trees. This means that each node has a specified number of titles - each in a different "language". Only one language set is visible at any given time. This is useful for maintaining the same structure in many languages (hence the name of the plugin)

## Configuration

Expects an array of language codes. Each of the items is used as a CSS class name, so make sure you specify only valid CSS class name strings. The first langauge will be visible onload. For example:

`[ "en", "de", "bg" ]`

## Demos

Check your data plugin documentation (html_data, xml_data, json_data) or take a close look at these examples for information on how to specify multilanguage nodes.

### Using the languages plugin with HTML data

- Root node 1 Корен 1
  - Child node 1 Дете 1
  - Child node 2 Дете 2
- Root node 2 Корен 2

## API

### .set_lang ( lang )

Set the tree's visible language. Triggers an event.

- `string
  number` lang

  Either the language code string (as specified in the config) or an index from the config array.

### .get_lang ( )

Returns the name of the currently visible language.

### ._get_string ( node , lang )

Returns the needed string from the core config object. Overwrites the get_string function from the core. If the key does not exist in that language, but exists in the root of the object - that is returned, if even that does not exist - the key itself is returned.

- `string` key

  The name of the string you are looking for. If you want to use the localize option just set the strings core config option to an object like this one: `strings : { "lang-code-here" : { "string-key" : "string-value" ... }, "other-lang" : { ... } }`, otherwise _get_strings won't be affected.

- `string` lang

  The language code string (as specified in the config) to get the key in. If not specified the currently visible language is used.

### .get_text ( node , lang )

Returns the title of a node. Overwrites the get_text function from the core.

- `mixed` node

  This can be a DOM node, jQuery node or selector pointing to the element whose title you need.

- `string` lang

  The language code string (as specified in the config) to get the title in. If you omit this - the currently visible language is used.

### .set_text ( node , text , lang )

Sets the title of a node. Overwrites the set_text function from the core. This is used internally - you should use rename_node. Since `rename_node` uses `set_text` internally you can pass a language string as a third parameter to rename_node.

- `mixed` node

  This can be a DOM node, jQuery node or selector pointing to the element whose title you want to change.

- `string` text

  The new title.

- `string` lang

  The language code string (as specified in the config) to get the title in. If you omit this - the currently visible language is used.

### ._load_css ( )

used only internally to include the CSS necessary for the plugin onload.

### .create_node ( obj , position , js , callback )

Overwrites the create_node function from the core. To create a node with a few titles use an array for the `data` property of the `js` parameter:

`{ "data" : [ { "title" : "EN title", language : "en" }, { "title" : "BG заглавие", language : "bg" } ] }`