Browse Source

Merge pull request #15503 from HypnosNova/docs

Documentation: Easier language switching
Mr.doob 6 years ago
parent
commit
cf065b67cc
1 changed files with 15 additions and 0 deletions
  1. 15 0
      docs/index.html

+ 15 - 0
docs/index.html

@@ -69,6 +69,8 @@
 
 
 				language = value;
 				language = value;
 				createNavigation();
 				createNavigation();
+				updateFilter();
+				autoChangeUrlLanguage( language );
 
 
 			}
 			}
 
 
@@ -226,6 +228,19 @@
 
 
 			}
 			}
 
 
+			// Auto change language url. If a reader open a document in English, when he click "zh", the document he read will auto change into Chinese version
+
+			function autoChangeUrlLanguage( language ) {
+
+				var hash = location.hash;
+				if ( hash === '' ) return;
+				var docType = hash.substr( 0, hash.indexOf( '/' ) + 1 );
+				var docLink = hash.substr( hash.indexOf( '/' ) + 1 );
+				docLink = docLink.substr( docLink.indexOf( '/' ) );
+				location.href = docType + language + docLink;
+
+			}
+
 
 
 			// Filtering
 			// Filtering