-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add translation zh-TW * add zh-TW to langs.js
- Loading branch information
1 parent
80cfbef
commit fe0a837
Showing
2 changed files
with
702 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,93 +1,98 @@ | ||
const supportLangs = [ | ||
{ | ||
name: 'English', | ||
value: 'en-US', | ||
icon: '🇺🇸', | ||
}, | ||
{ | ||
name: 'فارسی', | ||
value: 'fa-IR', | ||
icon: '🇮🇷', | ||
}, | ||
{ | ||
name: '中文', | ||
value: 'zh-CN', | ||
icon: '🇨🇳', | ||
}, | ||
{ | ||
name: 'Русский', | ||
value: 'ru-RU', | ||
icon: '🇷🇺', | ||
}, | ||
{ | ||
name: 'Tiếng Việt', | ||
value: 'vi-VN', | ||
icon: '🇻🇳', | ||
}, | ||
{ | ||
name: 'Español', | ||
value: 'es-ES', | ||
icon: '🇪🇸', | ||
}, | ||
{ | ||
name: 'Indonesian', | ||
value: 'id-ID', | ||
icon: '🇮🇩', | ||
}, | ||
{ | ||
name: 'Український', | ||
value: 'uk-UA', | ||
icon: '🇺🇦', | ||
}, | ||
{ | ||
name: 'Türkçe', | ||
value: 'tr-TR', | ||
icon: '🇹🇷', | ||
}, | ||
{ | ||
name: "Português", | ||
value: "pt-BR", | ||
icon: "🇧🇷", | ||
}, | ||
{ | ||
name: "English", | ||
value: "en-US", | ||
icon: "🇺🇸", | ||
}, | ||
{ | ||
name: "فارسی", | ||
value: "fa-IR", | ||
icon: "🇮🇷", | ||
}, | ||
{ | ||
name: "簡體中文", | ||
value: "zh-CN", | ||
icon: "🇨🇳", | ||
}, | ||
{ | ||
name: "繁體中文", | ||
value: "zh-TW", | ||
icon: "🇹🇼", | ||
}, | ||
{ | ||
name: "Русский", | ||
value: "ru-RU", | ||
icon: "🇷🇺", | ||
}, | ||
{ | ||
name: "Tiếng Việt", | ||
value: "vi-VN", | ||
icon: "🇻🇳", | ||
}, | ||
{ | ||
name: "Español", | ||
value: "es-ES", | ||
icon: "🇪🇸", | ||
}, | ||
{ | ||
name: "Indonesian", | ||
value: "id-ID", | ||
icon: "🇮🇩", | ||
}, | ||
{ | ||
name: "Український", | ||
value: "uk-UA", | ||
icon: "🇺🇦", | ||
}, | ||
{ | ||
name: "Türkçe", | ||
value: "tr-TR", | ||
icon: "🇹🇷", | ||
}, | ||
{ | ||
name: "Português", | ||
value: "pt-BR", | ||
icon: "🇧🇷", | ||
}, | ||
]; | ||
|
||
function getLang() { | ||
let lang = getCookie('lang'); | ||
let lang = getCookie("lang"); | ||
|
||
if (!lang) { | ||
if (window.navigator) { | ||
lang = window.navigator.language || window.navigator.userLanguage; | ||
if (!lang) { | ||
if (window.navigator) { | ||
lang = window.navigator.language || window.navigator.userLanguage; | ||
|
||
if (isSupportLang(lang)) { | ||
setCookie('lang', lang, 150); | ||
} else { | ||
setCookie('lang', 'en-US', 150); | ||
window.location.reload(); | ||
} | ||
} else { | ||
setCookie('lang', 'en-US', 150); | ||
window.location.reload(); | ||
} | ||
} | ||
if (isSupportLang(lang)) { | ||
setCookie("lang", lang, 150); | ||
} else { | ||
setCookie("lang", "en-US", 150); | ||
window.location.reload(); | ||
} | ||
} else { | ||
setCookie("lang", "en-US", 150); | ||
window.location.reload(); | ||
} | ||
} | ||
|
||
return lang; | ||
return lang; | ||
} | ||
|
||
function setLang(lang) { | ||
if (!isSupportLang(lang)) { | ||
lang = 'en-US'; | ||
} | ||
if (!isSupportLang(lang)) { | ||
lang = "en-US"; | ||
} | ||
|
||
setCookie('lang', lang, 150); | ||
window.location.reload(); | ||
setCookie("lang", lang, 150); | ||
window.location.reload(); | ||
} | ||
|
||
function isSupportLang(lang) { | ||
for (l of supportLangs) { | ||
if (l.value === lang) { | ||
return true; | ||
} | ||
} | ||
for (l of supportLangs) { | ||
if (l.value === lang) { | ||
return true; | ||
} | ||
} | ||
|
||
return false; | ||
return false; | ||
} |
Oops, something went wrong.