feat(i18n): traducir Requiere atención y redactar las alertas en cada idioma
Las alertas de shared suman razon + valores para que la web las redacte; etiqueta/detalle se mantienen en español para el backend. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -63,6 +63,8 @@ function attendanceAlert(member: MemberAttendance, now: Date): StudentAlert | nu
|
||||
gravedad: 'urgente',
|
||||
etiqueta: `${streak} seguidas`,
|
||||
detalle: `No viene hace ${streak} clases seguidas.`,
|
||||
razon: 'racha',
|
||||
valores: { faltas: streak },
|
||||
firma,
|
||||
peso: streak,
|
||||
};
|
||||
@@ -72,6 +74,8 @@ function attendanceAlert(member: MemberAttendance, now: Date): StudentAlert | nu
|
||||
gravedad: 'urgente',
|
||||
etiqueta: `${highWindow.absences} faltas`,
|
||||
detalle: `Faltó a ${highWindow.absences} de las últimas ${highWindow.classes} clases.`,
|
||||
razon: 'ventana',
|
||||
valores: { faltas: highWindow.absences, clases: highWindow.classes },
|
||||
firma,
|
||||
peso: highWindow.absences,
|
||||
};
|
||||
@@ -87,6 +91,8 @@ function attendanceAlert(member: MemberAttendance, now: Date): StudentAlert | nu
|
||||
absences === streak
|
||||
? `Faltó a las últimas ${absences} clases.`
|
||||
: `Faltó a ${absences} de las últimas ${classes} clases.`,
|
||||
razon: absences === streak ? 'ultimas' : 'ventana',
|
||||
valores: { faltas: absences, clases: classes },
|
||||
firma,
|
||||
peso: absences,
|
||||
};
|
||||
@@ -111,6 +117,8 @@ function paymentAlert(payments: StudentAlertInput['overduePayments']): StudentAl
|
||||
months.length === count
|
||||
? `Debe las cuotas de ${joinList(months)}.`
|
||||
: `Debe ${count} cuotas vencidas.`,
|
||||
razon: 'cuotas',
|
||||
valores: { cuotas: count, vencimientos: sorted.map((payment) => payment.dueDate) },
|
||||
firma,
|
||||
peso: count,
|
||||
};
|
||||
@@ -122,6 +130,8 @@ function paymentAlert(payments: StudentAlertInput['overduePayments']): StudentAl
|
||||
gravedad: 'vigilar',
|
||||
etiqueta: 'Cuota vencida',
|
||||
detalle: `La cuota de ${monthName(payment.dueDate)} venció el ${dayMonth(payment.dueDate)}.`,
|
||||
razon: 'cuota',
|
||||
valores: { cuotas: 1, vencimientos: [payment.dueDate] },
|
||||
firma,
|
||||
peso: count,
|
||||
};
|
||||
|
||||
@@ -12,6 +12,30 @@ export type StudentAlertType = z.output<typeof studentAlertTypeSchema>;
|
||||
export const studentAlertSeveritySchema = z.enum(['urgente', 'vigilar']);
|
||||
export type StudentAlertSeverity = z.output<typeof studentAlertSeveritySchema>;
|
||||
|
||||
/** Why the alert fired, so a client can word it in its own language
|
||||
* (`etiqueta`/`detalle` keep the Spanish wording). */
|
||||
export const studentAlertReasonSchema = z.enum([
|
||||
/** N absences in a row (`faltas`). */
|
||||
'racha',
|
||||
/** `faltas` out of the last `clases`. */
|
||||
'ventana',
|
||||
/** The last `faltas` classes (window == streak). */
|
||||
'ultimas',
|
||||
/** Two or more overdue fees (`cuotas`, `vencimientos`). */
|
||||
'cuotas',
|
||||
/** One overdue fee (`vencimientos[0]`). */
|
||||
'cuota',
|
||||
]);
|
||||
export type StudentAlertReason = z.output<typeof studentAlertReasonSchema>;
|
||||
|
||||
export const StudentAlertValuesSchema = z.object({
|
||||
faltas: z.number().int().optional(),
|
||||
clases: z.number().int().optional(),
|
||||
cuotas: z.number().int().optional(),
|
||||
/** Due dates (ISO) of the overdue fees, oldest first. */
|
||||
vencimientos: z.array(z.string()).optional(),
|
||||
});
|
||||
|
||||
export const StudentAlertSchema = z.object({
|
||||
tipo: studentAlertTypeSchema,
|
||||
gravedad: studentAlertSeveritySchema,
|
||||
@@ -19,6 +43,8 @@ export const StudentAlertSchema = z.object({
|
||||
etiqueta: z.string(),
|
||||
/** Natural-language line: "Faltó a 4 de las últimas 6 clases." */
|
||||
detalle: z.string(),
|
||||
razon: studentAlertReasonSchema.optional(),
|
||||
valores: StudentAlertValuesSchema.optional(),
|
||||
/** What the alert is about (last absence / overdue payments). "Resuelto"
|
||||
* stores it, so a new absence or a new overdue fee brings the alert back. */
|
||||
firma: z.string(),
|
||||
|
||||
Reference in New Issue
Block a user