Support multiple languages

This commit is contained in:
Urtzi Alfaro
2025-09-25 12:14:46 +02:00
parent 6d4090f825
commit f02a980c87
66 changed files with 3274 additions and 333 deletions

View File

@@ -1,6 +1,7 @@
import React, { forwardRef } from 'react';
import { clsx } from 'clsx';
import { useLocation, Link } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import { getBreadcrumbs, getRouteByPath } from '../../../router/routes.config';
import {
ChevronRight,
@@ -94,7 +95,7 @@ export const Breadcrumbs = forwardRef<BreadcrumbsRef, BreadcrumbsProps>(({
items: customItems,
showHome = true,
homePath = '/',
homeLabel = 'Inicio',
homeLabel,
separator,
maxItems = 5,
truncateMiddle = true,
@@ -103,9 +104,13 @@ export const Breadcrumbs = forwardRef<BreadcrumbsRef, BreadcrumbsProps>(({
hiddenPaths = [],
itemRenderer,
}, ref) => {
const { t } = useTranslation();
const location = useLocation();
const containerRef = React.useRef<HTMLDivElement>(null);
// Set default home label if not provided
const resolvedHomeLabel = homeLabel || t('common:breadcrumbs.home', 'Inicio');
// Get breadcrumbs from router config or use custom items
const routeBreadcrumbs = getBreadcrumbs(location.pathname);
@@ -115,11 +120,11 @@ export const Breadcrumbs = forwardRef<BreadcrumbsRef, BreadcrumbsProps>(({
}
const items: BreadcrumbItem[] = [];
// Add home if enabled
if (showHome && location.pathname !== homePath) {
items.push({
label: homeLabel,
label: resolvedHomeLabel,
path: homePath,
icon: Home,
});