Add italian localization
- Added it locale - Add it language ro other config files (nginx.conf, vite.config.ts, i18n.ts)
This commit is contained in:
@@ -3,7 +3,7 @@ import LanguageDetector from 'i18next-browser-languagedetector';
|
||||
import HttpBackend from 'i18next-http-backend';
|
||||
|
||||
// Supported languages
|
||||
export const supportedLanguages = ['en', 'de', 'zh', 'vi'] as const;
|
||||
export const supportedLanguages = ['en', 'de', 'zh', 'vi', 'it'] as const;
|
||||
export type SupportedLanguage = (typeof supportedLanguages)[number];
|
||||
|
||||
export const languageNames: Record<SupportedLanguage, string> = {
|
||||
@@ -11,11 +11,12 @@ export const languageNames: Record<SupportedLanguage, string> = {
|
||||
de: 'Deutsch',
|
||||
zh: '中文',
|
||||
vi: 'Tiếng Việt',
|
||||
it: 'Italiano',
|
||||
};
|
||||
|
||||
export const getLanguageFromUrl = (): SupportedLanguage => {
|
||||
const path = window.location.pathname;
|
||||
const langMatch = path.match(/^\/(en|de|zh|vi)(?:\/|$)/);
|
||||
const langMatch = path.match(/^\/(en|de|zh|vi|it)(?:\/|$)/);
|
||||
if (langMatch && supportedLanguages.includes(langMatch[1] as SupportedLanguage)) {
|
||||
return langMatch[1] as SupportedLanguage;
|
||||
}
|
||||
@@ -71,12 +72,12 @@ export const changeLanguage = (lang: SupportedLanguage): void => {
|
||||
const currentLang = getLanguageFromUrl();
|
||||
|
||||
let newPath: string;
|
||||
if (currentPath.match(/^\/(en|de|zh|vi)\//)) {
|
||||
newPath = currentPath.replace(/^\/(en|de|zh|vi)\//, `/${lang}/`);
|
||||
} else if (currentPath.match(/^\/(en|de|zh|vi)$/)) {
|
||||
newPath = `/${lang}`;
|
||||
if (currentPath.match(/^\/(en|de|zh|vi|it)\//)) {
|
||||
newPath = currentPath.replace(/^\/(en|de|zh|vi|it)\//, `/${lang}/`);
|
||||
} else if (currentPath.match(/^\/(en|de|zh|vi|it)$/)) {
|
||||
newPath = `/${lang}`;
|
||||
} else {
|
||||
newPath = `/${lang}${currentPath}`;
|
||||
newPath = `/${lang}${currentPath}`;
|
||||
}
|
||||
|
||||
const newUrl = newPath + window.location.search + window.location.hash;
|
||||
@@ -135,8 +136,8 @@ export const rewriteLinks = (): void => {
|
||||
return;
|
||||
}
|
||||
|
||||
if (href.match(/^\/(en|de|zh|vi)\//)) {
|
||||
return;
|
||||
if (href.match(/^\/(en|de|zh|vi|it)\//)) {
|
||||
return;
|
||||
}
|
||||
let newHref: string;
|
||||
if (href.startsWith('/')) {
|
||||
|
||||
Reference in New Issue
Block a user