feat: soporte multi idioma en la web (infraestructura)

i18next + react-i18next con es-AR (fuente), es-419, pt-BR y en; el idioma
sale del dispositivo (fallback a inglés) y se puede cambiar en Ajustes.
La elección se guarda en localStorage y, para el profe, en users.locale.
Las validaciones de shared pasan a claves y los errores de la API se
traducen por code (con params para límites de plan y cupo).
Migrados: layout, Ajustes, auth, PWA y lib/format.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jose Selesan
2026-11-03 12:14:59 -03:00
parent ff885bddfc
commit cb872eb8bc
102 changed files with 2332 additions and 290 deletions

View File

@@ -21,6 +21,7 @@ export function conflictProblem(params: {
detail: string;
code?: string;
instance?: string;
params?: ProblemDetails['params'];
}): ProblemDetails {
return {
type: `${PROBLEM_DOMAIN}/problems/conflict`,
@@ -29,6 +30,7 @@ export function conflictProblem(params: {
detail: params.detail,
instance: params.instance,
code: params.code,
...(params.params ? { params: params.params } : {}),
};
}
@@ -186,6 +188,7 @@ export function capacityReachedProblem(capacity: number | null): ProblemDetails
? `El grupo alcanzó su cupo máximo de ${capacity} miembros.`
: 'El grupo alcanzó su cupo máximo de miembros.',
code: 'group_capacity_reached',
...(capacity ? { params: { capacity } } : {}),
});
}
@@ -216,13 +219,18 @@ export function noAttendeesToBillProblem(): ProblemDetails {
code: 'no_attendees_to_bill',
});
}
function paymentRequiredProblem(params: { detail: string; code: string }): ProblemDetails {
function paymentRequiredProblem(params: {
detail: string;
code: string;
params?: ProblemDetails['params'];
}): ProblemDetails {
return {
type: `${PROBLEM_DOMAIN}/problems/plan`,
title: 'Payment Required',
status: 402,
detail: params.detail,
code: params.code,
...(params.params ? { params: params.params } : {}),
};
}
@@ -236,6 +244,7 @@ export function planLimitReachedProblem(limit: PlanLimitKind, max: number): Prob
? `El plan Free permite hasta ${max} ${max === 1 ? 'grupo' : 'grupos'}. Pasate a Pro para crear más.`
: `El plan Free permite hasta ${max} alumnos activos. Pasate a Pro para sumar más.`,
code: 'plan_limit_reached',
params: { limit, max },
});
}
@@ -247,6 +256,7 @@ export function planFeatureRequiredProblem(feature: 'mpCharges' | 'whatsappAutom
? 'Cobrar con Mercado Pago está disponible en el plan Pro.'
: 'Los mensajes automáticos de WhatsApp están disponibles en el plan Pro.',
code: 'plan_feature_required',
params: { feature },
});
}

View File

@@ -1,4 +1,5 @@
import { passkey } from '@better-auth/passkey';
import { appLocaleSchema } from '@gruperly/shared';
import { betterAuth } from 'better-auth';
import { prismaAdapter } from 'better-auth/adapters/prisma';
import { organization } from 'better-auth/plugins/organization';
@@ -11,6 +12,18 @@ export const auth = betterAuth({
database: prismaAdapter(getPrismaClient(), {
provider: 'postgresql',
}),
user: {
additionalFields: {
// UI language chosen in Ajustes; null means "follow the device". The web
// saves it with updateUser and reads it back from the session.
locale: {
type: 'string',
required: false,
input: true,
validator: { input: appLocaleSchema.nullable() },
},
},
},
emailAndPassword: {
enabled: true,
minPasswordLength: 8,