Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | 21x 21x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 2x 3x | import type { TFunction } from "i18next"; export function getErrorMessage(t: TFunction, code?: string) { // 1) on monte un traducteur dédié au namespace "errors" const te = (key: string) => t(key, { ns: 'errors' }); switch (code) { // Login / 2FA case 'invalid_credentials': return te('invalidCredentials'); case 'account_disabled': return te('accountDisabled'); case 'twofa_invalid': return te('twofaInvalid'); case 'twofa_required': return te('twofaRequired'); case 'user_not_found': return te('userNotFound'); case 'already_verified': return te('alreadyVerified'); case 'email_not_verified': return te('emailNotVerified'); case 'too_many_requests': return te('tooManyRequests'); // Registration case 'validation_error': return te('validationError'); case 'email_already_registered': return te('emailAlreadyRegistered'); case 'password_too_weak': return te('passwordTooWeak'); case 'captcha_failed': return te('captchaFailed'); case 'captcha_invalid': return te('captchaInvalid'); case 'terms_not_accepted': return te('termsNotAccepted'); // Server / Network case 'internal_error': return te('internalError'); case 'service_unavailable': return te('serviceUnavailable'); case 'network_error': return te('networkError'); // Generic fallback default: return te('genericError'); } } |