Here is the demo of the long and short JSON format for multilanguage trees. You need to set the languages option. In the buttons code, you can see how to get an instance - either by using reference and focused.
01.
$(
function
() {
02.
$(
"#l_json"
).tree({
03.
languages : [
"en"
,
"bg"
],
04.
data : {
05.
type :
"json"
,
06.
opts : {
07.
static : [
08.
{
09.
// the short format demo
10.
data : {
"en"
:
"A node"
,
"bg"
:
"Нодче"
},
11.
// here are the children
12.
children : [
13.
{ data : {
"en"
:
"Child node 1"
,
"bg"
:
"Дете 1"
} },
14.
{ data : {
"en"
:
"Child node 2"
,
"bg"
:
"Дете 2"
} }
15.
]
16.
},
17.
{
18.
attributes : {
"id"
:
"li.node.id"
},
19.
// this is the long data format
20.
data : {
21.
bg : {
22.
title :
"удри баце"
,
23.
attributes : {
"href"
:
"http://jstree.com"
}
24.
},
25.
en : {
26.
title :
"Long format demo"
,
27.
attributes : {
"href"
:
"http://jstree.com"
}
28.
}
29.
}
30.
}
31.
]
32.
}
33.
}
34.
});
35.
});
1.
<
input
type
=
"button"
onclick
=
"$.tree.focused().set_lang("
en");"
value
=
"English"
>
2.
<
input
type
=
"button"
onclick
=
"$.tree.reference("
#l_json").set_lang("bg");"
value
=
"Български"
>