@@ -22,6 +22,13 @@ <h1><a href="http://threejs.org">three.js</a> / docs</h1>
2222 < input type ="text " id ="filterInput " placeholder ="Type to filter " autocorrect ="off " autocapitalize ="off " spellcheck ="false ">
2323 < a href ="# " id ="clearFilterButton "> x</ a >
2424 </ div >
25+
26+ < div style ="text-align:center ">
27+ < br />
28+ < a href ="javascript:setLanguage('en') "> en</ a > |
29+ < a href ="javascript:setLanguage('zh') "> zh</ a >
30+ </ div >
31+
2532 < div id ="content "> </ div >
2633
2734 </ div >
@@ -44,6 +51,15 @@ <h1><a href="http://threejs.org">three.js</a> / docs</h1>
4451
4552 //
4653
54+ var language = 'en' ;
55+
56+ function setLanguage ( value ) {
57+
58+ language = value ;
59+ createNavigation ( ) ;
60+
61+ }
62+
4763 var panel = document . getElementById ( 'panel' ) ;
4864 var content = document . getElementById ( 'content' ) ;
4965 var clearFilterButton = document . getElementById ( 'clearFilterButton' ) ;
@@ -55,6 +71,8 @@ <h1><a href="http://threejs.org">three.js</a> / docs</h1>
5571 var titles = { } ;
5672 var categoryElements = [ ] ;
5773
74+ var navigation ;
75+
5876
5977 // Functionality for hamburger button (on small devices)
6078
@@ -118,16 +136,24 @@ <h1><a href="http://threejs.org">three.js</a> / docs</h1>
118136
119137 function createNavigation ( ) {
120138
139+ if ( navigation !== undefined ) {
140+
141+ content . removeChild ( navigation ) ;
142+
143+ }
144+
121145 // Create the navigation panel using data from list.js
122146
123- var navigation = document . createElement ( 'div' ) ;
147+ navigation = document . createElement ( 'div' ) ;
124148 content . appendChild ( navigation ) ;
125149
126- for ( var section in list ) {
150+ var localList = list [ language ] ;
151+
152+ for ( var section in localList ) {
127153
128154 // Create sections
129155
130- var categories = list [ section ] ;
156+ var categories = localList [ section ] ;
131157
132158 var sectionHead = document . createElement ( 'h2' ) ;
133159 sectionHead . textContent = section ;
@@ -157,8 +183,6 @@ <h1><a href="http://threejs.org">three.js</a> / docs</h1>
157183
158184 // Localisation
159185
160- pageURL = pageURL . replace ( '{lan}' , 'en' ) ;
161-
162186 var listElement = document . createElement ( 'li' ) ;
163187 categoryContent . appendChild ( listElement ) ;
164188
0 commit comments