docs: fix translation dropdown error (#4007)

This commit is contained in:
jeremywu 2021-10-23 01:23:49 +08:00 committed by GitHub
parent 6006e910aa
commit 7d581e0b53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -29,6 +29,11 @@ export const useTranslation = () => {
const langsCopy = langs.slice(0)
langsCopy.splice(langsCopy.indexOf(currentLang), 1)
// if current language is not zh-CN, then zh-CN needs to be moved to the head.
if (currentLang !== 'zh-CN') {
langsCopy.splice(langsCopy.indexOf('zh-CN'), 1)
}
return currentLang === 'zh-CN' ? langsCopy : ['zh-CN'].concat(langsCopy)
})