Skip to content

Commit 098fc84

Browse files
committed
add espanish translation
1 parent 755fc06 commit 098fc84

File tree

10 files changed

+130
-33
lines changed

10 files changed

+130
-33
lines changed

app/lib/presentation/resources/locale/generated/intl/messages_en.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ class MessageLookup extends MessageLookupByLibrary {
4848
),
4949
"labelEmail": MessageLookupByLibrary.simpleMessage("Email"),
5050
"labelPassword": MessageLookupByLibrary.simpleMessage("Password"),
51+
"loginErrorInvalidCredentials": MessageLookupByLibrary.simpleMessage(
52+
"Invalid email or password.",
53+
),
5154
"noConnection": MessageLookupByLibrary.simpleMessage("No connection"),
5255
"passwordInstructions": MessageLookupByLibrary.simpleMessage(
5356
"Min 8 characters long: 1 uppercase letter, 1 lowercase letter, 1 number, and 1 special character.",

app/lib/presentation/resources/locale/generated/intl/messages_es.dart

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,49 @@ class MessageLookup extends MessageLookupByLibrary {
2323
final messages = _notInlinedMessages(_notInlinedMessages);
2424
static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
2525
"appName": MessageLookupByLibrary.simpleMessage("Flutter Target"),
26-
"cookiesAcceptCTA": MessageLookupByLibrary.simpleMessage("Accept"),
26+
"cookiesAcceptCTA": MessageLookupByLibrary.simpleMessage("Aceptar"),
2727
"cookiesBody": MessageLookupByLibrary.simpleMessage(
28-
"We use cookies to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners who may combine it with other information that you’ve provided to them or that they’ve collected from your use of their services.",
28+
"Usamos cookies para personalizar el contenido y los anuncios, ofrecer funciones de redes sociales y analizar nuestro tráfico. También compartimos información sobre el uso de nuestro sitio con nuestros socios de redes sociales, publicidad y análisis, quienes pueden combinarla con otra información que les hayas proporcionado o que hayan recopilado a partir del uso de sus servicios.",
2929
),
3030
"cookiesTitle": MessageLookupByLibrary.simpleMessage(
31-
"This website uses cookies",
31+
"Este sitio web utiliza cookies",
3232
),
3333
"ctaLogin": MessageLookupByLibrary.simpleMessage("Iniciar sesión"),
34-
"noConnection": MessageLookupByLibrary.simpleMessage("No connection"),
34+
"errorEmailInvalid": MessageLookupByLibrary.simpleMessage(
35+
"Por favor ingresa una dirección de correo válida.",
36+
),
37+
"errorEmailRequired": MessageLookupByLibrary.simpleMessage(
38+
"El correo electrónico es obligatorio.",
39+
),
40+
"errorPasswordRequired": MessageLookupByLibrary.simpleMessage(
41+
"La contraseña es obligatoria.",
42+
),
43+
"errorPasswordWeak": MessageLookupByLibrary.simpleMessage(
44+
"La contraseña es demasiado débil.",
45+
),
46+
"labelAgreeToTerms": MessageLookupByLibrary.simpleMessage(
47+
"Acepto los Términos y Condiciones",
48+
),
49+
"labelEmail": MessageLookupByLibrary.simpleMessage("Correo electrónico"),
50+
"labelPassword": MessageLookupByLibrary.simpleMessage("Contraseña"),
51+
"loginErrorInvalidCredentials": MessageLookupByLibrary.simpleMessage(
52+
"Correo o contraseña inválidos.",
53+
),
54+
"noConnection": MessageLookupByLibrary.simpleMessage("Sin conexión"),
55+
"passwordInstructions": MessageLookupByLibrary.simpleMessage(
56+
"Mínimo 8 caracteres: 1 mayúscula, 1 minúscula, 1 número y 1 carácter especial.",
57+
),
3558
"pleaseTryAgainLaterWeArenworkingToFixTheIssue":
3659
MessageLookupByLibrary.simpleMessage(
37-
"Please try again later, we are\nworking to fix the issue.",
60+
"Por favor, inténtalo más tarde,\nestamos trabajando para resolver el problema.",
3861
),
39-
"retry": MessageLookupByLibrary.simpleMessage("Retry"),
62+
"retry": MessageLookupByLibrary.simpleMessage("Reintentar"),
4063
"sorryWeDidntFindAnyProduct": MessageLookupByLibrary.simpleMessage(
41-
"Sorry we didn\'t find any product",
64+
"Lo sentimos, no hemos encontrado ningún producto",
65+
),
66+
"titleLogin": MessageLookupByLibrary.simpleMessage("Iniciar sesión"),
67+
"titleLoginSubtitle": MessageLookupByLibrary.simpleMessage(
68+
"Usa tu correo y contraseña para iniciar sesión en tu cuenta.",
4269
),
4370
};
4471
}

app/lib/presentation/resources/locale/generated/l10n.dart

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/lib/presentation/resources/locale/intl_en.arb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@
1717
"titleLogin": "Login",
1818
"titleLoginSubtitle": "Use your email and password to login to your account.",
1919
"errorEmailInvalid": "Please enter a valid email address.",
20-
"errorPasswordWeak": "Password is too weak."
20+
"errorPasswordWeak": "Password is too weak.",
21+
"loginErrorInvalidCredentials": "Invalid email or password."
2122
}
Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
11
{
22
"appName": "Flutter Target",
3-
"cookiesTitle": "This website uses cookies",
4-
"cookiesAcceptCTA": "Accept",
5-
"cookiesBody": "We use cookies to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners who may combine it with other information that you’ve provided to them or that they’ve collected from your use of their services.",
6-
"noConnection": "No connection",
7-
"retry": "Retry",
8-
"pleaseTryAgainLaterWeArenworkingToFixTheIssue": "Please try again later, we are\nworking to fix the issue.",
9-
"sorryWeDidntFindAnyProduct": "Sorry we didn't find any product",
10-
"ctaLogin": "Iniciar sesión"
3+
"cookiesTitle": "Este sitio web utiliza cookies",
4+
"cookiesAcceptCTA": "Aceptar",
5+
"cookiesBody": "Usamos cookies para personalizar el contenido y los anuncios, ofrecer funciones de redes sociales y analizar nuestro tráfico. También compartimos información sobre el uso de nuestro sitio con nuestros socios de redes sociales, publicidad y análisis, quienes pueden combinarla con otra información que les hayas proporcionado o que hayan recopilado a partir del uso de sus servicios.",
6+
"noConnection": "Sin conexión",
7+
"retry": "Reintentar",
8+
"pleaseTryAgainLaterWeArenworkingToFixTheIssue": "Por favor, inténtalo más tarde,\nestamos trabajando para resolver el problema.",
9+
"sorryWeDidntFindAnyProduct": "Lo sentimos, no hemos encontrado ningún producto",
10+
"ctaLogin": "Iniciar sesión",
11+
"labelEmail": "Correo electrónico",
12+
"labelPassword": "Contraseña",
13+
"passwordInstructions": "Mínimo 8 caracteres: 1 mayúscula, 1 minúscula, 1 número y 1 carácter especial.",
14+
"labelAgreeToTerms": "Acepto los Términos y Condiciones",
15+
"errorEmailRequired": "El correo electrónico es obligatorio.",
16+
"errorPasswordRequired": "La contraseña es obligatoria.",
17+
"titleLogin": "Iniciar sesión",
18+
"titleLoginSubtitle": "Usa tu correo y contraseña para iniciar sesión en tu cuenta.",
19+
"errorEmailInvalid": "Por favor ingresa una dirección de correo válida.",
20+
"errorPasswordWeak": "La contraseña es demasiado débil.",
21+
"loginErrorInvalidCredentials": "Correo o contraseña inválidos."
1122
}

app/lib/presentation/ui/pages/auth/login/login_form.dart

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -119,19 +119,34 @@ class _LoginFormState extends State<LoginForm> {
119119
const Gap(Dimen.spacingM),
120120
BlocBuilder<AuthCubit, Resource>(
121121
builder: (context, state) {
122-
return PrimaryButton(
123-
label: S.of(context).ctaLogin,
124-
onPressed: () {
125-
if (_formKey.currentState?.validate() ?? false) {
126-
_authCubit.login(
127-
email: emailController.text,
128-
password: passwordController.text,
129-
);
130-
}
131-
},
132-
isEnabled: agreeToTerms,
133-
isLoading: state is RLoading,
134-
trailingIcon: const Icon(Icons.login),
122+
return Column(
123+
mainAxisSize: MainAxisSize.min,
124+
children: [
125+
if (state is RError) ...[
126+
Text(
127+
S.of(context).loginErrorInvalidCredentials,
128+
style:
129+
Theme.of(context).textTheme.headlineMedium?.copyWith(
130+
color: Theme.of(context).colorScheme.error,
131+
),
132+
),
133+
const Gap(Dimen.spacingM),
134+
],
135+
PrimaryButton(
136+
label: S.of(context).ctaLogin,
137+
onPressed: () {
138+
if (_formKey.currentState?.validate() ?? false) {
139+
_authCubit.login(
140+
email: emailController.text,
141+
password: passwordController.text,
142+
);
143+
}
144+
},
145+
isEnabled: agreeToTerms,
146+
isLoading: state is RLoading,
147+
trailingIcon: const Icon(Icons.login),
148+
)
149+
],
135150
);
136151
},
137152
),

modules/common/lib/core/resource.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ class RSuccess<T> extends Resource<T> {
2626

2727
class RError<T> extends Resource<T> {
2828
RError({super.state = RState.error, super.data, required super.exception});
29+
30+
get message => exception?.toString();
2931
}
3032

3133
enum RState {
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
class FormValidator {
2+
static bool isEmail(String? value) {
3+
if (value == null || value.isEmpty) {
4+
return false;
5+
}
6+
final emailRegex = RegExp(
7+
r"^[a-zA-Z0-9.a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9]+\.[a-zA-Z]+");
8+
return emailRegex.hasMatch(value);
9+
}
10+
11+
/// // At least 8 characters, one uppercase, one lowercase, one number and one special character
12+
static bool isStrongPassword(String? value) {
13+
if (value == null || value.isEmpty) {
14+
return false;
15+
}
16+
// At least 8 characters, one uppercase, one lowercase, one number and one special character
17+
final passwordRegex = RegExp(
18+
r'^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$');
19+
return passwordRegex.hasMatch(value);
20+
}
21+
}

modules/domain/lib/bloc/auth/auth_cubit.dart

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,15 @@ class AuthCubit extends BaseCubit<AuthState> {
88
final AuthService _authService;
99
AuthCubit(this._authService) : super(RSuccess(data: AuthStateUnknown()));
1010

11-
Future<void> login(String username, String password) async {
11+
Future<void> login({
12+
required String email,
13+
required String password,
14+
}) async {
1215
isLoading();
13-
final authResult =
14-
await _authService.logInWithCredentials(username, password);
16+
final authResult = await _authService.logInWithCredentials(
17+
email,
18+
password,
19+
);
1520

1621
authResult
1722
..mapSuccess((_) => isLogin())

modules/domain/lib/services/auth_service.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ class AuthService {
77
AuthService(this._authRepository);
88

99
Future<ResultType<void>> logInWithCredentials(
10-
String username, String password) =>
10+
String username,
11+
String password,
12+
) =>
1113
_authRepository.login(username, password);
1214

1315
bool isLoggedIn() => _authRepository.isLoggedIn();

0 commit comments

Comments
 (0)