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

API

.set_lang ( lang )

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

.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.

.get_text ( node , lang )

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

.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.

._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" } ] }