feat(i18n): Add French (Français) language support
This commit is contained in:
@@ -5,6 +5,7 @@ import HttpBackend from 'i18next-http-backend';
|
||||
// Supported languages
|
||||
export const supportedLanguages = [
|
||||
'en',
|
||||
'fr',
|
||||
'de',
|
||||
'zh',
|
||||
'vi',
|
||||
@@ -16,6 +17,7 @@ export type SupportedLanguage = (typeof supportedLanguages)[number];
|
||||
|
||||
export const languageNames: Record<SupportedLanguage, string> = {
|
||||
en: 'English',
|
||||
fr: 'Français',
|
||||
de: 'Deutsch',
|
||||
zh: '中文',
|
||||
vi: 'Tiếng Việt',
|
||||
@@ -26,7 +28,7 @@ export const languageNames: Record<SupportedLanguage, string> = {
|
||||
|
||||
export const getLanguageFromUrl = (): SupportedLanguage => {
|
||||
const path = window.location.pathname;
|
||||
const langMatch = path.match(/^\/(en|de|zh|vi|tr|id|it)(?:\/|$)/);
|
||||
const langMatch = path.match(/^\/(en|fr|de|zh|vi|tr|id|it)(?:\/|$)/);
|
||||
if (
|
||||
langMatch &&
|
||||
supportedLanguages.includes(langMatch[1] as SupportedLanguage)
|
||||
@@ -88,9 +90,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|vi|tr|id|it)\//)) {
|
||||
newPath = currentPath.replace(/^\/(en|fr|de|zh|vi|tr|id|it)\//, `/${lang}/`);
|
||||
} else if (currentPath.match(/^\/(en|fr|de|zh|vi|tr|id|it)$/)) {
|
||||
newPath = `/${lang}`;
|
||||
} else {
|
||||
newPath = `/${lang}${currentPath}`;
|
||||
@@ -154,7 +156,7 @@ export const rewriteLinks = (): void => {
|
||||
return;
|
||||
}
|
||||
|
||||
if (href.match(/^\/(en|de|zh|vi|tr|id|it)\//)) {
|
||||
if (href.match(/^\/(en|fr|de|zh|vi|tr|id|it)\//)) {
|
||||
return;
|
||||
}
|
||||
let newHref: string;
|
||||
|
||||
Reference in New Issue
Block a user