mirror of
https://github.com/rustdesk/doc.rustdesk.com.git
synced 2024-11-07 08:54:20 +01:00
remove "detect browser language", because currently, only the English
version has complete content, https://github.com/rustdesk/doc.rustdesk.com/pull/127
This commit is contained in:
parent
820ec1fe5e
commit
430aa54888
@ -1,97 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>{{ .Permalink }}</title>
|
||||
<link rel="canonical" href="{{ .Permalink }}"/>
|
||||
<meta name="robots" content="noindex">
|
||||
<meta charset="utf-8"/>
|
||||
<noscript>
|
||||
<meta http-equiv="refresh" content="0; url={{ .Permalink }}"/>
|
||||
</noscript>
|
||||
<script>
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
|
||||
var deleteFinalSlash = function(s){
|
||||
if ( s.substr(-1) == '/' ){
|
||||
return s.slice(0, -1)
|
||||
}else{
|
||||
return s
|
||||
}
|
||||
}
|
||||
|
||||
const default_language = '{{ site.Language.Lang }}'
|
||||
const wlp = deleteFinalSlash(window.location.pathname)
|
||||
const root_path = deleteFinalSlash( (new URL('{{ site.BaseURL }}')).pathname )
|
||||
|
||||
// Only do i18n at root,
|
||||
// otherwise, redirect immediately
|
||||
if ( wlp !== root_path) {
|
||||
window.location.replace('{{ .Permalink }}')
|
||||
return
|
||||
}
|
||||
|
||||
var getFirstBrowserLanguage = function () {
|
||||
var nav = window.navigator,
|
||||
browserLanguagePropertyKeys = ['language', 'browserLanguage', 'systemLanguage', 'userLanguage'],
|
||||
i,
|
||||
language
|
||||
|
||||
if (Array.isArray(nav.languages)) {
|
||||
for (i = 0; i < nav.languages.length; i++) {
|
||||
language = nav.languages[i]
|
||||
if (language && language.length) {
|
||||
return language.replace('_', '-').toLowerCase()
|
||||
}
|
||||
}
|
||||
}
|
||||
// support for other well known properties in browsers
|
||||
for (i = 0; i < browserLanguagePropertyKeys.length; i++) {
|
||||
language = nav[browserLanguagePropertyKeys[i]]
|
||||
if (language && language.length) {
|
||||
return language.replace('_', '-').toLowerCase()
|
||||
}
|
||||
}
|
||||
return default_language
|
||||
}
|
||||
|
||||
var languages_available = [];
|
||||
( {{ site.Languages }} ).forEach(
|
||||
function(value,index) {
|
||||
if ( value['Disabled'] == false ){
|
||||
languages_available.push(value['Lang'])
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
const nav_lang = getFirstBrowserLanguage()
|
||||
|
||||
var found_lang = default_language
|
||||
|
||||
if ( languages_available.indexOf( nav_lang ) !== -1 ){
|
||||
|
||||
found_lang = nav_lang
|
||||
|
||||
}else if ( nav_lang.length > 2 ) {
|
||||
|
||||
const short_code_lang = nav_lang.slice(0,2)
|
||||
|
||||
if ( languages_available.indexOf( short_code_lang ) !== -1 ){
|
||||
found_lang = short_code_lang
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
window.location.replace(`${root_path}/${found_lang}/`)
|
||||
|
||||
}
|
||||
)
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Rerouting</h1>
|
||||
<p>You should be rerouted, if not, <a href="{{ .Permalink }}">click here</a>.</p>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user