Merge branch 'main' into add-spanish-translation

This commit is contained in:
Alam
2026-01-13 22:45:05 +05:30
committed by GitHub
175 changed files with 12004 additions and 31398 deletions

View File

@@ -5,9 +5,11 @@ import HttpBackend from 'i18next-http-backend';
// Supported languages
export const supportedLanguages = [
'en',
'fr',
'de',
'es',
'zh',
'zh-TW',
'vi',
'tr',
'id',
@@ -17,9 +19,11 @@ export type SupportedLanguage = (typeof supportedLanguages)[number];
export const languageNames: Record<SupportedLanguage, string> = {
en: 'English',
fr: 'Français',
de: 'Deutsch',
es: 'Español',
zh: '中文',
"zh-TW": '繁體中文(台灣)',
vi: 'Tiếng Việt',
tr: 'Türkçe',
id: 'Bahasa Indonesia',
@@ -28,7 +32,8 @@ export const languageNames: Record<SupportedLanguage, string> = {
export const getLanguageFromUrl = (): SupportedLanguage => {
const path = window.location.pathname;
const langMatch = path.match(/^\/(en|de|es|zh|vi|tr|id|it)(?:\/|$)/);
const langMatch = path.match(/^\/(en|fr|es|de|zh|zh-TW|vi|tr|id|it)(?:\/|$)/);
if (
langMatch &&
supportedLanguages.includes(langMatch[1] as SupportedLanguage)
@@ -90,9 +95,9 @@ export const changeLanguage = (lang: SupportedLanguage): void => {
const currentLang = getLanguageFromUrl();
let newPath: string;
if (currentPath.match(/^\/(en|de|zh|vi|tr|id|it)\//)) {
newPath = currentPath.replace(/^\/(en|de|zh|vi|tr|id|it)\//, `/${lang}/`);
} else if (currentPath.match(/^\/(en|de|zh|vi|tr|id|it)$/)) {
if (currentPath.match(/^\/(en|fr|de|zh|zh-TW|vi|tr|id|it)\//)) {
newPath = currentPath.replace(/^\/(en|fr|de|zh|zh-TW|vi|tr|id|it)\//, `/${lang}/`);
} else if (currentPath.match(/^\/(en|fr|de|zh|zh-TW|vi|tr|id|it)$/)) {
newPath = `/${lang}`;
} else {
newPath = `/${lang}${currentPath}`;
@@ -156,7 +161,7 @@ export const rewriteLinks = (): void => {
return;
}
if (href.match(/^\/(en|de|zh|vi|tr|id|it)\//)) {
if (href.match(/^\/(en|fr|de|zh|zh-TW|vi|tr|id|it)\//)) {
return;
}
let newHref: string;