0
0
Fork 0

login transalations amends

This commit is contained in:
Carlos Jimenez Ruiz 2022-02-28 17:00:06 +01:00
parent c1726c2bce
commit 4edb7de3ad
4 changed files with 38534 additions and 38500 deletions

76944
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,22 @@
{ {
"message": "hello i18n !!", "globals": {
"Username": "Usuario" "lang": {
"es": "Spanish",
"en": "English"
}
},
"login": {
"title": "Login",
"username": "Username",
"password": "Password",
"submit": "Log in",
"keepLogin": "Keep me logged in",
"loginSuccess": "You have successfully logged in",
"loginError": "Invalid username or password"
},
"customer": {},
"components": {
"dialog": {},
"calendar": {}
}
} }

View File

@ -1,22 +1,22 @@
{ {
"globals": { "globals": {
"Shipped": "Enviado", "lang": {
"Landed": "Aterrizado" "es": "Español",
"en": "Inglés"
}
}, },
"login": { "login": {
"title": "Iniciar sesión", "title": "Iniciar sesión",
"username": "Nombre de usuario", "username": "Nombre de usuario",
"password": "Contraseña", "password": "Contraseña",
"submit": "Iniciar sesión", "submit": "Iniciar sesión",
"keepLogin": "Mantener sesión iniciada" "keepLogin": "Mantener sesión iniciada",
"loginSuccess": "Inicio de sesión correcto",
"loginError": "Nombre de usuario o contraseña incorrectos"
}, },
"customer": {}, "customer": {},
"components": { "components": {
"dialog": { "dialog": {},
"calendar": {}
},
"calendar": {
}
} }
} }

View File

@ -3,6 +3,14 @@
<q-header class="transparent"> <q-header class="transparent">
<q-toolbar> <q-toolbar>
<q-space></q-space> <q-space></q-space>
<q-toggle
:label="$t(`globals.lang['${language}']`)"
icon="public"
color="orange"
false-value="es"
true-value="en"
v-model="language"
/>
<q-toggle v-model="mode" checked-icon="dark_mode" color="orange" unchecked-icon="light_mode" /> <q-toggle v-model="mode" checked-icon="dark_mode" color="orange" unchecked-icon="light_mode" />
</q-toolbar> </q-toolbar>
</q-header> </q-header>
@ -47,26 +55,21 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { Options, Vue } from 'vue-class-component'; import { Vue } from 'vue-class-component';
import { Dark, useQuasar } from 'quasar'; import { Dark, useQuasar } from 'quasar';
import axios from 'axios'; import axios from 'axios';
@Options({ interface LoginForm {
i18n: { username: string;
messages: { password: string;
es: { keepLogin: boolean;
Password: 'Contraseña', Dark: Dark;
'Keep logged in': 'Mantener sesión iniciada', }
Login: 'Iniciar sesión',
'Login failed': 'Inicio de sesión fallido',
},
},
},
})
export default class Login extends Vue { export default class Login extends Vue {
username?: string; username?: string;
password?: string; password?: string;
keepLogin?: boolean; keepLogin?: boolean;
private lang = 'es';
setup() { setup() {
return { return {
@ -74,12 +77,6 @@ export default class Login extends Vue {
}; };
} }
mounted() {
this.$i18n.locale = 'es';
//this.$q.lang.set();
console.log(this.$i18n.locale);
}
get mode(): boolean { get mode(): boolean {
return Dark.isActive; return Dark.isActive;
} }
@ -88,6 +85,15 @@ export default class Login extends Vue {
Dark.set(value); Dark.set(value);
} }
get language(): string {
return this.lang;
}
set language(value: string) {
this.lang = value;
this.$i18n.locale = value;
}
onSubmit(): void { onSubmit(): void {
axios axios
.post('/api/accounts/login', { .post('/api/accounts/login', {
@ -96,20 +102,20 @@ export default class Login extends Vue {
}) })
.then(() => { .then(() => {
this.$q.notify({ this.$q.notify({
message: 'Login success', message: this.$t('login.loginSuccess'),
type: 'positive', type: 'positive',
}); });
this.$router.push('/dashboard'); this.$router.push('/dashboard');
}) })
.catch(() => .catch(() =>
this.$q.notify({ this.$q.notify({
message: this.$t('Login failed'), message: this.$t('login.loginError'),
type: 'negative', type: 'negative',
}) })
); );
} }
data() { data(): LoginForm {
return { return {
username: '', username: '',
password: '', password: '',