feat(i18n): traducir Grupos (lista, ficha, alta de miembros y estadísticas)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { i18n } from '../i18n/instance';
|
||||
|
||||
export type ParsedContactRow = {
|
||||
id: string;
|
||||
firstName: string;
|
||||
@@ -141,7 +143,7 @@ export async function parseXlsxContent(buffer: ArrayBuffer): Promise<string[][]>
|
||||
// Parse sheet1.xml
|
||||
const sheetData = entries.get('xl/worksheets/sheet1.xml');
|
||||
if (!sheetData) {
|
||||
throw new Error('No se pudo encontrar la hoja de cálculo principal en el archivo Excel.');
|
||||
throw new Error(i18n.t('groupAdd:bulk.noSheet'));
|
||||
}
|
||||
|
||||
const sheetXml = new TextDecoder().decode(sheetData);
|
||||
@@ -191,13 +193,15 @@ export function normalizeRowsToContacts(rawRows: string[][]): ParsedContactRow[]
|
||||
|
||||
for (let i = 0; i < headerRow.length; i++) {
|
||||
const col = headerRow[i];
|
||||
if (col === 'nombre' || col === 'first name' || col === 'firstname') {
|
||||
if (col === 'nombre' || col === 'nome' || col === 'first name' || col === 'firstname') {
|
||||
firstNameCol = i;
|
||||
hasHeader = true;
|
||||
} else if (col === 'apellido' || col === 'last name' || col === 'lastname') {
|
||||
} else if (col === 'apellido' || col === 'sobrenome' || col === 'last name' || col === 'lastname') {
|
||||
lastNameCol = i;
|
||||
hasHeader = true;
|
||||
} else if (col === 'nombre completo' || col === 'full name' || col === 'fullname' || col === 'alumno') {
|
||||
} else if (
|
||||
['nombre completo', 'nome completo', 'full name', 'fullname', 'alumno', 'aluno', 'student'].includes(col)
|
||||
) {
|
||||
nameCol = i;
|
||||
hasHeader = true;
|
||||
} else if (
|
||||
@@ -213,7 +217,7 @@ export function normalizeRowsToContacts(rawRows: string[][]): ParsedContactRow[]
|
||||
} else if (col.includes('email') || col.includes('correo')) {
|
||||
emailCol = i;
|
||||
hasHeader = true;
|
||||
} else if (col.includes('nota') || col.includes('obs')) {
|
||||
} else if (col.includes('nota') || col.includes('note') || col.includes('obs')) {
|
||||
notesCol = i;
|
||||
hasHeader = true;
|
||||
}
|
||||
@@ -269,9 +273,9 @@ export function normalizeRowsToContacts(rawRows: string[][]): ParsedContactRow[]
|
||||
const notes = (notesCol !== -1 ? row[notesCol] : '') || '';
|
||||
|
||||
const errors: string[] = [];
|
||||
if (!firstName && !fullName) errors.push('Falta el nombre');
|
||||
if (!firstName && !fullName) errors.push(i18n.t('groupAdd:bulk.missingName'));
|
||||
if (!phone || phone.replace(/\D/g, '').length < 6) {
|
||||
errors.push('Teléfono inválido o faltante');
|
||||
errors.push(i18n.t('groupAdd:bulk.invalidPhone'));
|
||||
}
|
||||
|
||||
contacts.push({
|
||||
@@ -294,11 +298,10 @@ export function normalizeRowsToContacts(rawRows: string[][]): ParsedContactRow[]
|
||||
* Downloads a sample template in CSV format for the bulk upload.
|
||||
*/
|
||||
export function downloadAttendeeTemplateCsv() {
|
||||
// The template follows the UI language; the parser accepts the headers of
|
||||
// every supported language.
|
||||
const csvContent =
|
||||
'Nombre,Apellido,Teléfono,Email,Notas\r\n' +
|
||||
'Sofía,Rodríguez,+5491144556677,sofia@ejemplo.com,Nivel intermedio\r\n' +
|
||||
'Lucas,Benítez,+5491155667788,lucas@ejemplo.com,Trae instrumento\r\n' +
|
||||
'Valentina,Morales,+5491166778899,,\r\n';
|
||||
[i18n.t('groupAdd:template.header'), ...i18n.t('groupAdd:template.rows').split('\n')].join('\r\n') + '\r\n';
|
||||
|
||||
const blob = new Blob([new Uint8Array([0xef, 0xbb, 0xbf]), csvContent], {
|
||||
type: 'text/csv;charset=utf-8;',
|
||||
@@ -306,7 +309,7 @@ export function downloadAttendeeTemplateCsv() {
|
||||
const url = URL.createObjectURL(blob);
|
||||
const link = document.createElement('a');
|
||||
link.setAttribute('href', url);
|
||||
link.setAttribute('download', 'plantilla_alumnos_gruperly.csv');
|
||||
link.setAttribute('download', i18n.t('groupAdd:template.fileName'));
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
|
||||
Reference in New Issue
Block a user