Skip to content

Commit

Permalink
add language zh-Tw (#2572)
Browse files Browse the repository at this point in the history
* add translation zh-TW

* add zh-TW to langs.js
  • Loading branch information
xellosiris authored Oct 3, 2024
1 parent 80cfbef commit fe0a837
Show file tree
Hide file tree
Showing 2 changed files with 702 additions and 77 deletions.
159 changes: 82 additions & 77 deletions web/assets/js/langs.js
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;
}
Loading

0 comments on commit fe0a837

Please sign in to comment.