Set html “lang” attribute based on URL hash

Required to trigger auto-translate feature in applicable Chromium-based browsers (Chrome & Edge)
This commit is contained in:
John Hildenbiddle
2021-02-04 14:40:12 -06:00
parent eee9507d43
commit cf5c7431f1
2 changed files with 16 additions and 0 deletions
+8
View File
@@ -56,6 +56,14 @@
<body>
<div id="app">Loading ...</div>
<script>
// Set html "lang" attribute based on URL
var lang = location.hash.match(/#\/(de-de|es|ru-ru|zh-cn)\//);
if (lang) {
document.documentElement.setAttribute('lang', lang[1]);
}
// Docsify configuration
window.$docsify = {
alias: {
'.*?/awesome':
+8
View File
@@ -26,6 +26,14 @@
<body>
<div id="app"></div>
<script>
// Set html "lang" attribute based on URL
var lang = location.hash.match(/#\/(de-de|es|ru-ru|zh-cn)\//);
if (lang) {
document.documentElement.setAttribute('lang', lang[1]);
}
// Docsify configuration
window.$docsify = {
alias: {
'.*?/awesome': 'https://raw.githubusercontent.com/docsifyjs/awesome-docsify/master/README.md',