feat(core_localization): add error translation utility and new error messages

feat(client_auth): implement error handling with localized messages
feat(client_hubs): implement error handling with localized messages
feat(client_billing): navigate to home after billing
feat(client_coverage): navigate to home after coverage
feat(client_create_order): navigate to home after create order
feat(client_settings): navigate to home after settings
feat(client_view_orders): show hub name in order card
fix(client_auth): handle existing firebase accounts during sign-up

This commit introduces a new utility function, `translateErrorKey`,
to translate error message keys to localized strings. It also adds
new error messages to the localization files for both English and
Spanish.

The commit also implements error handling with localized messages in
the client authentication and hubs features. This makes it easier for
users to understand what went wrong and how to fix it.

Additionally, the commit updates the navigation flow for the billing,
coverage, create order, and settings features to navigate to the home
page after the user completes the action.

Finally, the commit fixes a bug where the hub name was not being
displayed in the order card.
This commit is contained in:
bwnyasse
2026-01-31 18:56:48 -05:00
parent 9517606e7a
commit caac050ac9
30 changed files with 1396 additions and 105 deletions

View File

@@ -8,3 +8,4 @@ export 'src/domain/usecases/set_locale_use_case.dart';
export 'src/data/repositories_impl/locale_repository_impl.dart';
export 'src/data/datasources/locale_local_data_source.dart';
export 'src/localization_module.dart';
export 'src/utils/error_translator.dart';

View File

@@ -728,6 +728,60 @@
"paid": "Paid",
"pending": "Pending"
}
},
"errors": {
"auth": {
"invalid_credentials": "The email or password you entered is incorrect.",
"account_exists": "An account with this email already exists. Try signing in instead.",
"session_expired": "Your session has expired. Please sign in again.",
"user_not_found": "We couldn't find your account. Please check your email and try again.",
"unauthorized_app": "This account is not authorized for this app.",
"weak_password": "Please choose a stronger password with at least 8 characters.",
"sign_up_failed": "We couldn't create your account. Please try again.",
"sign_in_failed": "We couldn't sign you in. Please try again.",
"not_authenticated": "Please sign in to continue.",
"password_mismatch": "This email is already registered. Please use the correct password or tap 'Forgot Password' to reset it.",
"google_only_account": "This email is registered via Google. Please use 'Forgot Password' to set a password, then try signing up again with the same information."
},
"hub": {
"has_orders": "This hub has active orders and cannot be deleted.",
"not_found": "The hub you're looking for doesn't exist.",
"creation_failed": "We couldn't create the hub. Please try again."
},
"order": {
"missing_hub": "Please select a location for your order.",
"missing_vendor": "Please select a vendor for your order.",
"creation_failed": "We couldn't create your order. Please try again.",
"shift_creation_failed": "We couldn't schedule the shift. Please try again.",
"missing_business": "Your business profile couldn't be loaded. Please sign in again."
},
"profile": {
"staff_not_found": "Your profile couldn't be loaded. Please sign in again.",
"business_not_found": "Your business profile couldn't be loaded. Please sign in again.",
"update_failed": "We couldn't update your profile. Please try again."
},
"shift": {
"no_open_roles": "There are no open positions available for this shift.",
"application_not_found": "Your application couldn't be found.",
"no_active_shift": "You don't have an active shift to clock out from."
},
"generic": {
"unknown": "Something went wrong. Please try again.",
"no_connection": "No internet connection. Please check your network and try again."
}
},
"success": {
"hub": {
"created": "Hub created successfully!",
"deleted": "Hub deleted successfully!",
"nfc_assigned": "NFC tag assigned successfully!"
},
"order": {
"created": "Order created successfully!"
},
"profile": {
"updated": "Profile updated successfully!"
}
}
}

View File

@@ -727,5 +727,59 @@
"paid": "Pagado",
"pending": "Pendiente"
}
},
"errors": {
"auth": {
"invalid_credentials": "El correo electrónico o la contraseña que ingresaste es incorrecta.",
"account_exists": "Ya existe una cuenta con este correo electrónico. Intenta iniciar sesión.",
"session_expired": "Tu sesión ha expirado. Por favor, inicia sesión de nuevo.",
"user_not_found": "No pudimos encontrar tu cuenta. Por favor, verifica tu correo electrónico e intenta de nuevo.",
"unauthorized_app": "Esta cuenta no está autorizada para esta aplicación.",
"weak_password": "Por favor, elige una contraseña más segura con al menos 8 caracteres.",
"sign_up_failed": "No pudimos crear tu cuenta. Por favor, intenta de nuevo.",
"sign_in_failed": "No pudimos iniciar sesión. Por favor, intenta de nuevo.",
"not_authenticated": "Por favor, inicia sesión para continuar.",
"password_mismatch": "Este correo ya está registrado. Por favor, usa la contraseña correcta o toca 'Olvidé mi contraseña' para restablecerla.",
"google_only_account": "Este correo está registrado con Google. Por favor, usa 'Olvidé mi contraseña' para establecer una contraseña, luego intenta registrarte de nuevo con la misma información."
},
"hub": {
"has_orders": "Este hub tiene órdenes activas y no puede ser eliminado.",
"not_found": "El hub que buscas no existe.",
"creation_failed": "No pudimos crear el hub. Por favor, intenta de nuevo."
},
"order": {
"missing_hub": "Por favor, selecciona una ubicación para tu orden.",
"missing_vendor": "Por favor, selecciona un proveedor para tu orden.",
"creation_failed": "No pudimos crear tu orden. Por favor, intenta de nuevo.",
"shift_creation_failed": "No pudimos programar el turno. Por favor, intenta de nuevo.",
"missing_business": "No se pudo cargar tu perfil de empresa. Por favor, inicia sesión de nuevo."
},
"profile": {
"staff_not_found": "No se pudo cargar tu perfil. Por favor, inicia sesión de nuevo.",
"business_not_found": "No se pudo cargar tu perfil de empresa. Por favor, inicia sesión de nuevo.",
"update_failed": "No pudimos actualizar tu perfil. Por favor, intenta de nuevo."
},
"shift": {
"no_open_roles": "No hay posiciones abiertas disponibles para este turno.",
"application_not_found": "No se pudo encontrar tu solicitud.",
"no_active_shift": "No tienes un turno activo para registrar salida."
},
"generic": {
"unknown": "Algo salió mal. Por favor, intenta de nuevo.",
"no_connection": "Sin conexión a internet. Por favor, verifica tu red e intenta de nuevo."
}
},
"success": {
"hub": {
"created": "¡Hub creado exitosamente!",
"deleted": "¡Hub eliminado exitosamente!",
"nfc_assigned": "¡Etiqueta NFC asignada exitosamente!"
},
"order": {
"created": "¡Orden creada exitosamente!"
},
"profile": {
"updated": "¡Perfil actualizado exitosamente!"
}
}
}

View File

@@ -4,9 +4,9 @@
/// To regenerate, run: `dart run slang`
///
/// Locales: 2
/// Strings: 1044 (522 per locale)
/// Strings: 1108 (554 per locale)
///
/// Built on 2026-01-31 at 13:17 UTC
/// Built on 2026-01-31 at 17:08 UTC
// coverage:ignore-file
// ignore_for_file: type=lint, unused_import

View File

@@ -57,6 +57,8 @@ class Translations with BaseTranslations<AppLocale, Translations> {
late final TranslationsStaffProfileAttireEn staff_profile_attire = TranslationsStaffProfileAttireEn._(_root);
late final TranslationsStaffShiftsEn staff_shifts = TranslationsStaffShiftsEn._(_root);
late final TranslationsStaffTimeCardEn staff_time_card = TranslationsStaffTimeCardEn._(_root);
late final TranslationsErrorsEn errors = TranslationsErrorsEn._(_root);
late final TranslationsSuccessEn success = TranslationsSuccessEn._(_root);
}
// Path: common
@@ -420,6 +422,33 @@ class TranslationsStaffTimeCardEn {
late final TranslationsStaffTimeCardStatusEn status = TranslationsStaffTimeCardStatusEn._(_root);
}
// Path: errors
class TranslationsErrorsEn {
TranslationsErrorsEn._(this._root);
final Translations _root; // ignore: unused_field
// Translations
late final TranslationsErrorsAuthEn auth = TranslationsErrorsAuthEn._(_root);
late final TranslationsErrorsHubEn hub = TranslationsErrorsHubEn._(_root);
late final TranslationsErrorsOrderEn order = TranslationsErrorsOrderEn._(_root);
late final TranslationsErrorsProfileEn profile = TranslationsErrorsProfileEn._(_root);
late final TranslationsErrorsShiftEn shift = TranslationsErrorsShiftEn._(_root);
late final TranslationsErrorsGenericEn generic = TranslationsErrorsGenericEn._(_root);
}
// Path: success
class TranslationsSuccessEn {
TranslationsSuccessEn._(this._root);
final Translations _root; // ignore: unused_field
// Translations
late final TranslationsSuccessHubEn hub = TranslationsSuccessHubEn._(_root);
late final TranslationsSuccessOrderEn order = TranslationsSuccessOrderEn._(_root);
late final TranslationsSuccessProfileEn profile = TranslationsSuccessProfileEn._(_root);
}
// Path: staff_authentication.get_started_page
class TranslationsStaffAuthenticationGetStartedPageEn {
TranslationsStaffAuthenticationGetStartedPageEn._(this._root);
@@ -1745,6 +1774,183 @@ class TranslationsStaffTimeCardStatusEn {
String get pending => 'Pending';
}
// Path: errors.auth
class TranslationsErrorsAuthEn {
TranslationsErrorsAuthEn._(this._root);
final Translations _root; // ignore: unused_field
// Translations
/// en: 'The email or password you entered is incorrect.'
String get invalid_credentials => 'The email or password you entered is incorrect.';
/// en: 'An account with this email already exists. Try signing in instead.'
String get account_exists => 'An account with this email already exists. Try signing in instead.';
/// en: 'Your session has expired. Please sign in again.'
String get session_expired => 'Your session has expired. Please sign in again.';
/// en: 'We couldn't find your account. Please check your email and try again.'
String get user_not_found => 'We couldn\'t find your account. Please check your email and try again.';
/// en: 'This account is not authorized for this app.'
String get unauthorized_app => 'This account is not authorized for this app.';
/// en: 'Please choose a stronger password with at least 8 characters.'
String get weak_password => 'Please choose a stronger password with at least 8 characters.';
/// en: 'We couldn't create your account. Please try again.'
String get sign_up_failed => 'We couldn\'t create your account. Please try again.';
/// en: 'We couldn't sign you in. Please try again.'
String get sign_in_failed => 'We couldn\'t sign you in. Please try again.';
/// en: 'Please sign in to continue.'
String get not_authenticated => 'Please sign in to continue.';
/// en: 'This email is already registered. Please use the correct password or tap 'Forgot Password' to reset it.'
String get password_mismatch => 'This email is already registered. Please use the correct password or tap \'Forgot Password\' to reset it.';
/// en: 'This email is registered via Google. Please use 'Forgot Password' to set a password, then try signing up again with the same information.'
String get google_only_account => 'This email is registered via Google. Please use \'Forgot Password\' to set a password, then try signing up again with the same information.';
}
// Path: errors.hub
class TranslationsErrorsHubEn {
TranslationsErrorsHubEn._(this._root);
final Translations _root; // ignore: unused_field
// Translations
/// en: 'This hub has active orders and cannot be deleted.'
String get has_orders => 'This hub has active orders and cannot be deleted.';
/// en: 'The hub you're looking for doesn't exist.'
String get not_found => 'The hub you\'re looking for doesn\'t exist.';
/// en: 'We couldn't create the hub. Please try again.'
String get creation_failed => 'We couldn\'t create the hub. Please try again.';
}
// Path: errors.order
class TranslationsErrorsOrderEn {
TranslationsErrorsOrderEn._(this._root);
final Translations _root; // ignore: unused_field
// Translations
/// en: 'Please select a location for your order.'
String get missing_hub => 'Please select a location for your order.';
/// en: 'Please select a vendor for your order.'
String get missing_vendor => 'Please select a vendor for your order.';
/// en: 'We couldn't create your order. Please try again.'
String get creation_failed => 'We couldn\'t create your order. Please try again.';
/// en: 'We couldn't schedule the shift. Please try again.'
String get shift_creation_failed => 'We couldn\'t schedule the shift. Please try again.';
/// en: 'Your business profile couldn't be loaded. Please sign in again.'
String get missing_business => 'Your business profile couldn\'t be loaded. Please sign in again.';
}
// Path: errors.profile
class TranslationsErrorsProfileEn {
TranslationsErrorsProfileEn._(this._root);
final Translations _root; // ignore: unused_field
// Translations
/// en: 'Your profile couldn't be loaded. Please sign in again.'
String get staff_not_found => 'Your profile couldn\'t be loaded. Please sign in again.';
/// en: 'Your business profile couldn't be loaded. Please sign in again.'
String get business_not_found => 'Your business profile couldn\'t be loaded. Please sign in again.';
/// en: 'We couldn't update your profile. Please try again.'
String get update_failed => 'We couldn\'t update your profile. Please try again.';
}
// Path: errors.shift
class TranslationsErrorsShiftEn {
TranslationsErrorsShiftEn._(this._root);
final Translations _root; // ignore: unused_field
// Translations
/// en: 'There are no open positions available for this shift.'
String get no_open_roles => 'There are no open positions available for this shift.';
/// en: 'Your application couldn't be found.'
String get application_not_found => 'Your application couldn\'t be found.';
/// en: 'You don't have an active shift to clock out from.'
String get no_active_shift => 'You don\'t have an active shift to clock out from.';
}
// Path: errors.generic
class TranslationsErrorsGenericEn {
TranslationsErrorsGenericEn._(this._root);
final Translations _root; // ignore: unused_field
// Translations
/// en: 'Something went wrong. Please try again.'
String get unknown => 'Something went wrong. Please try again.';
/// en: 'No internet connection. Please check your network and try again.'
String get no_connection => 'No internet connection. Please check your network and try again.';
}
// Path: success.hub
class TranslationsSuccessHubEn {
TranslationsSuccessHubEn._(this._root);
final Translations _root; // ignore: unused_field
// Translations
/// en: 'Hub created successfully!'
String get created => 'Hub created successfully!';
/// en: 'Hub deleted successfully!'
String get deleted => 'Hub deleted successfully!';
/// en: 'NFC tag assigned successfully!'
String get nfc_assigned => 'NFC tag assigned successfully!';
}
// Path: success.order
class TranslationsSuccessOrderEn {
TranslationsSuccessOrderEn._(this._root);
final Translations _root; // ignore: unused_field
// Translations
/// en: 'Order created successfully!'
String get created => 'Order created successfully!';
}
// Path: success.profile
class TranslationsSuccessProfileEn {
TranslationsSuccessProfileEn._(this._root);
final Translations _root; // ignore: unused_field
// Translations
/// en: 'Profile updated successfully!'
String get updated => 'Profile updated successfully!';
}
// Path: staff_authentication.profile_setup_page.steps
class TranslationsStaffAuthenticationProfileSetupPageStepsEn {
TranslationsStaffAuthenticationProfileSetupPageStepsEn._(this._root);
@@ -3216,6 +3422,38 @@ extension on Translations {
'staff_time_card.status.disputed' => 'Disputed',
'staff_time_card.status.paid' => 'Paid',
'staff_time_card.status.pending' => 'Pending',
'errors.auth.invalid_credentials' => 'The email or password you entered is incorrect.',
'errors.auth.account_exists' => 'An account with this email already exists. Try signing in instead.',
'errors.auth.session_expired' => 'Your session has expired. Please sign in again.',
'errors.auth.user_not_found' => 'We couldn\'t find your account. Please check your email and try again.',
'errors.auth.unauthorized_app' => 'This account is not authorized for this app.',
'errors.auth.weak_password' => 'Please choose a stronger password with at least 8 characters.',
'errors.auth.sign_up_failed' => 'We couldn\'t create your account. Please try again.',
'errors.auth.sign_in_failed' => 'We couldn\'t sign you in. Please try again.',
'errors.auth.not_authenticated' => 'Please sign in to continue.',
'errors.auth.password_mismatch' => 'This email is already registered. Please use the correct password or tap \'Forgot Password\' to reset it.',
'errors.auth.google_only_account' => 'This email is registered via Google. Please use \'Forgot Password\' to set a password, then try signing up again with the same information.',
'errors.hub.has_orders' => 'This hub has active orders and cannot be deleted.',
'errors.hub.not_found' => 'The hub you\'re looking for doesn\'t exist.',
'errors.hub.creation_failed' => 'We couldn\'t create the hub. Please try again.',
'errors.order.missing_hub' => 'Please select a location for your order.',
'errors.order.missing_vendor' => 'Please select a vendor for your order.',
'errors.order.creation_failed' => 'We couldn\'t create your order. Please try again.',
'errors.order.shift_creation_failed' => 'We couldn\'t schedule the shift. Please try again.',
'errors.order.missing_business' => 'Your business profile couldn\'t be loaded. Please sign in again.',
'errors.profile.staff_not_found' => 'Your profile couldn\'t be loaded. Please sign in again.',
'errors.profile.business_not_found' => 'Your business profile couldn\'t be loaded. Please sign in again.',
'errors.profile.update_failed' => 'We couldn\'t update your profile. Please try again.',
'errors.shift.no_open_roles' => 'There are no open positions available for this shift.',
'errors.shift.application_not_found' => 'Your application couldn\'t be found.',
'errors.shift.no_active_shift' => 'You don\'t have an active shift to clock out from.',
'errors.generic.unknown' => 'Something went wrong. Please try again.',
'errors.generic.no_connection' => 'No internet connection. Please check your network and try again.',
'success.hub.created' => 'Hub created successfully!',
'success.hub.deleted' => 'Hub deleted successfully!',
'success.hub.nfc_assigned' => 'NFC tag assigned successfully!',
'success.order.created' => 'Order created successfully!',
'success.profile.updated' => 'Profile updated successfully!',
_ => null,
};
}

View File

@@ -54,6 +54,8 @@ class TranslationsEs with BaseTranslations<AppLocale, Translations> implements T
@override late final _TranslationsStaffProfileAttireEs staff_profile_attire = _TranslationsStaffProfileAttireEs._(_root);
@override late final _TranslationsStaffShiftsEs staff_shifts = _TranslationsStaffShiftsEs._(_root);
@override late final _TranslationsStaffTimeCardEs staff_time_card = _TranslationsStaffTimeCardEs._(_root);
@override late final _TranslationsErrorsEs errors = _TranslationsErrorsEs._(_root);
@override late final _TranslationsSuccessEs success = _TranslationsSuccessEs._(_root);
}
// Path: common
@@ -310,6 +312,33 @@ class _TranslationsStaffTimeCardEs implements TranslationsStaffTimeCardEn {
@override late final _TranslationsStaffTimeCardStatusEs status = _TranslationsStaffTimeCardStatusEs._(_root);
}
// Path: errors
class _TranslationsErrorsEs implements TranslationsErrorsEn {
_TranslationsErrorsEs._(this._root);
final TranslationsEs _root; // ignore: unused_field
// Translations
@override late final _TranslationsErrorsAuthEs auth = _TranslationsErrorsAuthEs._(_root);
@override late final _TranslationsErrorsHubEs hub = _TranslationsErrorsHubEs._(_root);
@override late final _TranslationsErrorsOrderEs order = _TranslationsErrorsOrderEs._(_root);
@override late final _TranslationsErrorsProfileEs profile = _TranslationsErrorsProfileEs._(_root);
@override late final _TranslationsErrorsShiftEs shift = _TranslationsErrorsShiftEs._(_root);
@override late final _TranslationsErrorsGenericEs generic = _TranslationsErrorsGenericEs._(_root);
}
// Path: success
class _TranslationsSuccessEs implements TranslationsSuccessEn {
_TranslationsSuccessEs._(this._root);
final TranslationsEs _root; // ignore: unused_field
// Translations
@override late final _TranslationsSuccessHubEs hub = _TranslationsSuccessHubEs._(_root);
@override late final _TranslationsSuccessOrderEs order = _TranslationsSuccessOrderEs._(_root);
@override late final _TranslationsSuccessProfileEs profile = _TranslationsSuccessProfileEs._(_root);
}
// Path: staff_authentication.get_started_page
class _TranslationsStaffAuthenticationGetStartedPageEs implements TranslationsStaffAuthenticationGetStartedPageEn {
_TranslationsStaffAuthenticationGetStartedPageEs._(this._root);
@@ -1080,6 +1109,119 @@ class _TranslationsStaffTimeCardStatusEs implements TranslationsStaffTimeCardSta
@override String get pending => 'Pendiente';
}
// Path: errors.auth
class _TranslationsErrorsAuthEs implements TranslationsErrorsAuthEn {
_TranslationsErrorsAuthEs._(this._root);
final TranslationsEs _root; // ignore: unused_field
// Translations
@override String get invalid_credentials => 'El correo electrónico o la contraseña que ingresaste es incorrecta.';
@override String get account_exists => 'Ya existe una cuenta con este correo electrónico. Intenta iniciar sesión.';
@override String get session_expired => 'Tu sesión ha expirado. Por favor, inicia sesión de nuevo.';
@override String get user_not_found => 'No pudimos encontrar tu cuenta. Por favor, verifica tu correo electrónico e intenta de nuevo.';
@override String get unauthorized_app => 'Esta cuenta no está autorizada para esta aplicación.';
@override String get weak_password => 'Por favor, elige una contraseña más segura con al menos 8 caracteres.';
@override String get sign_up_failed => 'No pudimos crear tu cuenta. Por favor, intenta de nuevo.';
@override String get sign_in_failed => 'No pudimos iniciar sesión. Por favor, intenta de nuevo.';
@override String get not_authenticated => 'Por favor, inicia sesión para continuar.';
@override String get password_mismatch => 'Este correo ya está registrado. Por favor, usa la contraseña correcta o toca \'Olvidé mi contraseña\' para restablecerla.';
@override String get google_only_account => 'Este correo está registrado con Google. Por favor, usa \'Olvidé mi contraseña\' para establecer una contraseña, luego intenta registrarte de nuevo con la misma información.';
}
// Path: errors.hub
class _TranslationsErrorsHubEs implements TranslationsErrorsHubEn {
_TranslationsErrorsHubEs._(this._root);
final TranslationsEs _root; // ignore: unused_field
// Translations
@override String get has_orders => 'Este hub tiene órdenes activas y no puede ser eliminado.';
@override String get not_found => 'El hub que buscas no existe.';
@override String get creation_failed => 'No pudimos crear el hub. Por favor, intenta de nuevo.';
}
// Path: errors.order
class _TranslationsErrorsOrderEs implements TranslationsErrorsOrderEn {
_TranslationsErrorsOrderEs._(this._root);
final TranslationsEs _root; // ignore: unused_field
// Translations
@override String get missing_hub => 'Por favor, selecciona una ubicación para tu orden.';
@override String get missing_vendor => 'Por favor, selecciona un proveedor para tu orden.';
@override String get creation_failed => 'No pudimos crear tu orden. Por favor, intenta de nuevo.';
@override String get shift_creation_failed => 'No pudimos programar el turno. Por favor, intenta de nuevo.';
@override String get missing_business => 'No se pudo cargar tu perfil de empresa. Por favor, inicia sesión de nuevo.';
}
// Path: errors.profile
class _TranslationsErrorsProfileEs implements TranslationsErrorsProfileEn {
_TranslationsErrorsProfileEs._(this._root);
final TranslationsEs _root; // ignore: unused_field
// Translations
@override String get staff_not_found => 'No se pudo cargar tu perfil. Por favor, inicia sesión de nuevo.';
@override String get business_not_found => 'No se pudo cargar tu perfil de empresa. Por favor, inicia sesión de nuevo.';
@override String get update_failed => 'No pudimos actualizar tu perfil. Por favor, intenta de nuevo.';
}
// Path: errors.shift
class _TranslationsErrorsShiftEs implements TranslationsErrorsShiftEn {
_TranslationsErrorsShiftEs._(this._root);
final TranslationsEs _root; // ignore: unused_field
// Translations
@override String get no_open_roles => 'No hay posiciones abiertas disponibles para este turno.';
@override String get application_not_found => 'No se pudo encontrar tu solicitud.';
@override String get no_active_shift => 'No tienes un turno activo para registrar salida.';
}
// Path: errors.generic
class _TranslationsErrorsGenericEs implements TranslationsErrorsGenericEn {
_TranslationsErrorsGenericEs._(this._root);
final TranslationsEs _root; // ignore: unused_field
// Translations
@override String get unknown => 'Algo salió mal. Por favor, intenta de nuevo.';
@override String get no_connection => 'Sin conexión a internet. Por favor, verifica tu red e intenta de nuevo.';
}
// Path: success.hub
class _TranslationsSuccessHubEs implements TranslationsSuccessHubEn {
_TranslationsSuccessHubEs._(this._root);
final TranslationsEs _root; // ignore: unused_field
// Translations
@override String get created => '¡Hub creado exitosamente!';
@override String get deleted => '¡Hub eliminado exitosamente!';
@override String get nfc_assigned => '¡Etiqueta NFC asignada exitosamente!';
}
// Path: success.order
class _TranslationsSuccessOrderEs implements TranslationsSuccessOrderEn {
_TranslationsSuccessOrderEs._(this._root);
final TranslationsEs _root; // ignore: unused_field
// Translations
@override String get created => '¡Orden creada exitosamente!';
}
// Path: success.profile
class _TranslationsSuccessProfileEs implements TranslationsSuccessProfileEn {
_TranslationsSuccessProfileEs._(this._root);
final TranslationsEs _root; // ignore: unused_field
// Translations
@override String get updated => '¡Perfil actualizado exitosamente!';
}
// Path: staff_authentication.profile_setup_page.steps
class _TranslationsStaffAuthenticationProfileSetupPageStepsEs implements TranslationsStaffAuthenticationProfileSetupPageStepsEn {
_TranslationsStaffAuthenticationProfileSetupPageStepsEs._(this._root);
@@ -2153,6 +2295,38 @@ extension on TranslationsEs {
'staff_time_card.status.disputed' => 'Disputado',
'staff_time_card.status.paid' => 'Pagado',
'staff_time_card.status.pending' => 'Pendiente',
'errors.auth.invalid_credentials' => 'El correo electrónico o la contraseña que ingresaste es incorrecta.',
'errors.auth.account_exists' => 'Ya existe una cuenta con este correo electrónico. Intenta iniciar sesión.',
'errors.auth.session_expired' => 'Tu sesión ha expirado. Por favor, inicia sesión de nuevo.',
'errors.auth.user_not_found' => 'No pudimos encontrar tu cuenta. Por favor, verifica tu correo electrónico e intenta de nuevo.',
'errors.auth.unauthorized_app' => 'Esta cuenta no está autorizada para esta aplicación.',
'errors.auth.weak_password' => 'Por favor, elige una contraseña más segura con al menos 8 caracteres.',
'errors.auth.sign_up_failed' => 'No pudimos crear tu cuenta. Por favor, intenta de nuevo.',
'errors.auth.sign_in_failed' => 'No pudimos iniciar sesión. Por favor, intenta de nuevo.',
'errors.auth.not_authenticated' => 'Por favor, inicia sesión para continuar.',
'errors.auth.password_mismatch' => 'Este correo ya está registrado. Por favor, usa la contraseña correcta o toca \'Olvidé mi contraseña\' para restablecerla.',
'errors.auth.google_only_account' => 'Este correo está registrado con Google. Por favor, usa \'Olvidé mi contraseña\' para establecer una contraseña, luego intenta registrarte de nuevo con la misma información.',
'errors.hub.has_orders' => 'Este hub tiene órdenes activas y no puede ser eliminado.',
'errors.hub.not_found' => 'El hub que buscas no existe.',
'errors.hub.creation_failed' => 'No pudimos crear el hub. Por favor, intenta de nuevo.',
'errors.order.missing_hub' => 'Por favor, selecciona una ubicación para tu orden.',
'errors.order.missing_vendor' => 'Por favor, selecciona un proveedor para tu orden.',
'errors.order.creation_failed' => 'No pudimos crear tu orden. Por favor, intenta de nuevo.',
'errors.order.shift_creation_failed' => 'No pudimos programar el turno. Por favor, intenta de nuevo.',
'errors.order.missing_business' => 'No se pudo cargar tu perfil de empresa. Por favor, inicia sesión de nuevo.',
'errors.profile.staff_not_found' => 'No se pudo cargar tu perfil. Por favor, inicia sesión de nuevo.',
'errors.profile.business_not_found' => 'No se pudo cargar tu perfil de empresa. Por favor, inicia sesión de nuevo.',
'errors.profile.update_failed' => 'No pudimos actualizar tu perfil. Por favor, intenta de nuevo.',
'errors.shift.no_open_roles' => 'No hay posiciones abiertas disponibles para este turno.',
'errors.shift.application_not_found' => 'No se pudo encontrar tu solicitud.',
'errors.shift.no_active_shift' => 'No tienes un turno activo para registrar salida.',
'errors.generic.unknown' => 'Algo salió mal. Por favor, intenta de nuevo.',
'errors.generic.no_connection' => 'Sin conexión a internet. Por favor, verifica tu red e intenta de nuevo.',
'success.hub.created' => '¡Hub creado exitosamente!',
'success.hub.deleted' => '¡Hub eliminado exitosamente!',
'success.hub.nfc_assigned' => '¡Etiqueta NFC asignada exitosamente!',
'success.order.created' => '¡Orden creada exitosamente!',
'success.profile.updated' => '¡Perfil actualizado exitosamente!',
_ => null,
};
}

View File

@@ -0,0 +1,139 @@
import '../l10n/strings.g.dart';
/// Translates error message keys to localized strings.
///
/// This utility function takes a dot-notation key like 'errors.auth.account_exists'
/// and returns the corresponding localized string from the translation system.
///
/// If the key is not found or doesn't match the expected format, the original
/// key is returned as a fallback.
///
/// Example:
/// ```dart
/// final message = translateErrorKey('errors.auth.account_exists');
/// // Returns: "An account with this email already exists. Try signing in instead."
/// ```
String translateErrorKey(String key) {
final List<String> parts = key.split('.');
// Expected format: errors.{category}.{error_type}
if (parts.length != 3 || parts[0] != 'errors') {
return key;
}
final String category = parts[1];
final String errorType = parts[2];
switch (category) {
case 'auth':
return _translateAuthError(errorType);
case 'hub':
return _translateHubError(errorType);
case 'order':
return _translateOrderError(errorType);
case 'profile':
return _translateProfileError(errorType);
case 'shift':
return _translateShiftError(errorType);
case 'generic':
return _translateGenericError(errorType);
default:
return key;
}
}
String _translateAuthError(String errorType) {
switch (errorType) {
case 'invalid_credentials':
return t.errors.auth.invalid_credentials;
case 'account_exists':
return t.errors.auth.account_exists;
case 'session_expired':
return t.errors.auth.session_expired;
case 'user_not_found':
return t.errors.auth.user_not_found;
case 'unauthorized_app':
return t.errors.auth.unauthorized_app;
case 'weak_password':
return t.errors.auth.weak_password;
case 'sign_up_failed':
return t.errors.auth.sign_up_failed;
case 'sign_in_failed':
return t.errors.auth.sign_in_failed;
case 'not_authenticated':
return t.errors.auth.not_authenticated;
case 'password_mismatch':
return t.errors.auth.password_mismatch;
case 'google_only_account':
return t.errors.auth.google_only_account;
default:
return t.errors.generic.unknown;
}
}
String _translateHubError(String errorType) {
switch (errorType) {
case 'has_orders':
return t.errors.hub.has_orders;
case 'not_found':
return t.errors.hub.not_found;
case 'creation_failed':
return t.errors.hub.creation_failed;
default:
return t.errors.generic.unknown;
}
}
String _translateOrderError(String errorType) {
switch (errorType) {
case 'missing_hub':
return t.errors.order.missing_hub;
case 'missing_vendor':
return t.errors.order.missing_vendor;
case 'creation_failed':
return t.errors.order.creation_failed;
case 'shift_creation_failed':
return t.errors.order.shift_creation_failed;
case 'missing_business':
return t.errors.order.missing_business;
default:
return t.errors.generic.unknown;
}
}
String _translateProfileError(String errorType) {
switch (errorType) {
case 'staff_not_found':
return t.errors.profile.staff_not_found;
case 'business_not_found':
return t.errors.profile.business_not_found;
case 'update_failed':
return t.errors.profile.update_failed;
default:
return t.errors.generic.unknown;
}
}
String _translateShiftError(String errorType) {
switch (errorType) {
case 'no_open_roles':
return t.errors.shift.no_open_roles;
case 'application_not_found':
return t.errors.shift.application_not_found;
case 'no_active_shift':
return t.errors.shift.no_active_shift;
default:
return t.errors.generic.unknown;
}
}
String _translateGenericError(String errorType) {
switch (errorType) {
case 'unknown':
return t.errors.generic.unknown;
case 'no_connection':
return t.errors.generic.no_connection;
default:
return t.errors.generic.unknown;
}
}