Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cf5c743

Browse files
committed
Set html “lang” attribute based on URL hash
Required to trigger auto-translate feature in applicable Chromium-based browsers (Chrome & Edge)
1 parent eee9507 commit cf5c743

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

docs/index.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@
5656
<body>
5757
<div id="app">Loading ...</div>
5858
<script>
59+
// Set html "lang" attribute based on URL
60+
var lang = location.hash.match(/#\/(de-de|es|ru-ru|zh-cn)\//);
61+
62+
if (lang) {
63+
document.documentElement.setAttribute('lang', lang[1]);
64+
}
65+
66+
// Docsify configuration
5967
window.$docsify = {
6068
alias: {
6169
'.*?/awesome':

index.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@
2626
<body>
2727
<div id="app"></div>
2828
<script>
29+
// Set html "lang" attribute based on URL
30+
var lang = location.hash.match(/#\/(de-de|es|ru-ru|zh-cn)\//);
31+
32+
if (lang) {
33+
document.documentElement.setAttribute('lang', lang[1]);
34+
}
35+
36+
// Docsify configuration
2937
window.$docsify = {
3038
alias: {
3139
'.*?/awesome': 'https://raw.githubusercontent.com/docsifyjs/awesome-docsify/master/README.md',

0 commit comments

Comments
 (0)