From 124c1ab95eb998beb71124017813617e4249e9ca Mon Sep 17 00:00:00 2001 From: Robin Jullian <38robin38@gmail.com> Date: Sat, 22 Dec 2018 15:14:50 +0100 Subject: [PATCH] fully translate auth --- app/index.html | 3 +++ app/modules/auth.js | 38 +++++++++++++++++--------------------- app/modules/modales.js | 12 ++++++------ app/modules/settings.js | 20 ++++++++++---------- app/views/settings.html | 4 ++-- lang/en_US/messages.json | 16 ++++++++++++++++ lang/fr_FR/messages.json | 16 ++++++++++++++++ 7 files changed, 70 insertions(+), 39 deletions(-) diff --git a/app/index.html b/app/index.html index 66d1b15..16447bb 100644 --- a/app/index.html +++ b/app/index.html @@ -136,6 +136,9 @@ \ No newline at end of file diff --git a/app/modules/auth.js b/app/modules/auth.js index b674d9d..871c58b 100644 --- a/app/modules/auth.js +++ b/app/modules/auth.js @@ -16,15 +16,15 @@ const auth = { tooggleMethod () { if (!isSignUp) { document.getElementById('conf_pass_textbox').style.display = 'block' - document.querySelector('.methodeBtn').innerHTML = 'SIGNUP' - document.getElementById('methodText').innerHTML = 'Signup' - document.querySelector('.askOtherMethode').innerHTML = `YOU HAVE ALREADY AN ACCOUNT ? LOG-IN YOU HERE` + document.querySelector('.methodeBtn').innerHTML = lang('AUTH_SIGNUP').toUpperCase() + document.getElementById('methodText').innerHTML = lang('AUTH_SIGNUP') + document.querySelector('.askOtherMethode').innerHTML = lang('AUTH_ASK_FOR_SIGNIN') isSignUp = true } else { document.getElementById('conf_pass_textbox').style.display = 'none' - document.querySelector('.methodeBtn').innerHTML = 'SIGNIN' - document.getElementById('methodText').innerHTML = 'Signin' - document.querySelector('.askOtherMethode').innerHTML = `YOU DON'T HAVE ANY ACCOUNT ? SIGN-UP HERE` + document.querySelector('.methodeBtn').innerHTML = lang('AUTH_SIGNIN').toUpperCase() + document.getElementById('methodText').innerHTML = lang('AUTH_SIGNIN') + document.querySelector('.askOtherMethode').innerHTML = lang('AUTH_ASK_FOR_SIGNUP') isSignUp = false } }, @@ -52,14 +52,13 @@ const auth = { if (emailTextBox !== "" && emailTextBox.includes('@') && emailTextBox.includes('.')) { if (passwordTextBox !== "") { - if (passwordTextBox.length > 8) { if (passwordTextBox === confPasswordTextBox) { let body = { email: emailTextBox, password: passwordTextBox } - + fetch(`${config.api}/auth/signup`, { method: 'post', body: JSON.stringify(body), @@ -74,23 +73,20 @@ const auth = { this.closeView() } else if (data.message === 'AUTH_BAD_PASSWORD') { - this.setError('Wrong password') + this.setError(lang('AUTH_BAD_PASSWORD')) } else if (data.message === 'AUTH_USER_NOT_FOUND') { - this.setError('User not found') + this.setError(lang('AUTH_USER_NOT_FOUND')) } }) } else { - this.setError('password do not match') + this.setError(lang('AUTH_PASSWORD_DONT_MATCH')) } } else { - this.setError('password must be more than 8 char') - } - } else { - this.setError('password mus be set') + this.setError(lang('AUTH_INVALID_PASSWORD')) } } else { - this.setError('Bad email') + this.setError(lang('AUTH_INVALID_EMAIL')) } }, @@ -116,7 +112,7 @@ const auth = { // To uncomment /* if (nobodySaveTheWorld) { - let years = 2018 + let years = 2019 while (years < 2074) { console.log('work') years++ @@ -133,17 +129,17 @@ const auth = { this.closeView() } else if (data.message === 'AUTH_BAD_PASSWORD') { - this.setError('Wrong password') + this.setError(lang('AUTH_BAD_PASSWORD')) } else if (data.message === 'AUTH_USER_NOT_FOUND') { - this.setError('User not found') + this.setError(lang('AUTH_USER_NOT_FOUND')) } }) } else { - this.setError('password mus be set') + this.setError(lang('AUTH_INVALID_PASSWORD')) } } else { - this.setError('Bad email') + this.setError(lang('AUTH_INVALID_EMAIL')) } }, diff --git a/app/modules/modales.js b/app/modules/modales.js index f55c9fd..6508e50 100644 --- a/app/modules/modales.js +++ b/app/modules/modales.js @@ -120,9 +120,9 @@ const modales = { inputs.push( '
', '
', - '', - '', - '', + ``, + ``, + ``, '
', '
' ) @@ -130,17 +130,17 @@ const modales = { vex.dialog.buttons.YES.text = lang('CONTINUE_BUTTON') vex.dialog.buttons.NO.text = lang('CANCEL_BUTTON') vex.dialog.open({ - message: 'change password', + message: lang('AUTH_CHANGE_PASSWORD'), input: inputs.join(''), callback: (data) => { if (data && data.oldPassword !== undefined && data.newPassword !== undefined) { if (data.newPassword === data.confirmNewPassword) { callback(data.oldPassword, data.newPassword) } else { - alert('passwords d\'ont match') + alert(lang('AUTH_PASSWORD_DONT_MATCH')) } } else { - alert('Bad password') + alert(lang('AUTH_INVALID_PASSWORD')) } } }) diff --git a/app/modules/settings.js b/app/modules/settings.js index ad51953..d5995d0 100644 --- a/app/modules/settings.js +++ b/app/modules/settings.js @@ -87,6 +87,8 @@ const settings = { document.getElementById('accountTitle').innerHTML = lang('SETTINGS_ACCOUNT') document.getElementById('accountStatus').innerHTML = lang('SETTINGS_ACCOUNT_STATUS') document.getElementById('accountSettings').innerHTML = lang('SETTINGS_ACCOUNT_PASSWORD') + document.getElementById('logoutButton').value = lang('AUTH_LOGOUT').toUpperCase() + document.getElementById('signinButton').value = lang('AUTH_SIGNIN').toUpperCase() document.querySelector('.version').innerHTML = `VERSION ${require('electron').remote.app.getVersion()}` }, @@ -298,16 +300,14 @@ const settings = { }).then(res => res.json()).catch((e) => { alert(`error : ${e}`) }).then((data) => { - console.log(data) - if (data.message === 'success') { - alert(`Success ! an email was send to : ${data.email}`) - this.logout() - } else if (data.message === "BAD_PASSWORD") { - alert('bad password') - } else { - alert(`error with the server`) - } - }) + if (data.message === 'success') { + this.logout() + } else if (data.message === "BAD_PASSWORD") { + alert(lang('AUTH_BAD_PASSWORD')) + } else { + alert(lang('AUTH_SERVER_ERROR')) + } + }) }) } diff --git a/app/views/settings.html b/app/views/settings.html index 7b1ab33..c764622 100644 --- a/app/views/settings.html +++ b/app/views/settings.html @@ -88,8 +88,8 @@

Stat

- - + +
diff --git a/lang/en_US/messages.json b/lang/en_US/messages.json index 48a7f31..d0c6ada 100644 --- a/lang/en_US/messages.json +++ b/lang/en_US/messages.json @@ -25,6 +25,22 @@ {"value": "SETTINGS_ACCOUNT_STATUS", "message": "Status"}, {"value": "SETTINGS_ACCOUNT_PASSWORD", "message": "Change password"}, + {"value": "AUTH_SIGNUP", "message": "Signup"}, + {"value": "AUTH_LOGOUT", "message": "Logout"}, + {"value": "AUTH_SIGNIN", "message": "Signin"}, + {"value": "AUTH_ASK_FOR_SIGNUP", "message": "YOU DON'T HAVE ANY ACCOUNT ? SIGN-UP HERE"}, + {"value": "AUTH_ASK_FOR_SIGNIN", "message": "YOU HAVE ALREADY AN ACCOUNT ? LOG-IN YOU HERE"}, + {"value": "AUTH_BAD_PASSWORD", "message": "Bad password"}, + {"value": "AUTH_USER_NOT_FOUND", "message": "User not found"}, + {"value": "AUTH_PASSWORD_DONT_MATCH", "message": "Passwords do not match"}, + {"value": "AUTH_SERVER_ERROR", "message": "A problem has occurred with the authentication server"}, + {"value": "AUTH_OLD_PASSWORD", "message": "Old password"}, + {"value": "AUTH_NEW_PASSWORD", "message": "New password"}, + {"value": "AUTH_CONF_PASSWORD", "message": "Confirm password"}, + {"value": "AUTH_CHANGE_PASSWORD", "message": "change the password"}, + {"value": "AUTH_INVALID_PASSWORD", "message": "Please enter a valid password"}, + {"value": "AUTH_INVALID_EMAIL", "message": "Please enter a valid email"}, + {"value": "CONTINUE_BUTTON", "message": "continue"}, {"value": "CANCEL_BUTTON", "message": "cancel"}, {"value": "SEARCH_BUTTON", "message": "Search"}, diff --git a/lang/fr_FR/messages.json b/lang/fr_FR/messages.json index 40b770a..d8fc7b3 100644 --- a/lang/fr_FR/messages.json +++ b/lang/fr_FR/messages.json @@ -25,6 +25,22 @@ {"value": "SETTINGS_ACCOUNT_STATUS", "message": "Statut"}, {"value": "SETTINGS_ACCOUNT_PASSWORD", "message": "Changer le mot de passe"}, + {"value": "AUTH_SIGNUP", "message": "Inscription"}, + {"value": "AUTH_LOGOUT", "message": "Déconnexion"}, + {"value": "AUTH_SIGNIN", "message": "Connexion"}, + {"value": "AUTH_ASK_FOR_SIGNUP", "message": "VOUS N'AVEZ PAS DE COMPTE ? INSCRIVE VOUS ICI"}, + {"value": "AUTH_ASK_FOR_SIGNIN", "message": "VOUS AVEZ DEJA UN COMPTE ? CONNECTER VOUS ICI"}, + {"value": "AUTH_BAD_PASSWORD", "message": "Mauvais mot de passe"}, + {"value": "AUTH_USER_NOT_FOUND", "message": "Utilisateur introuvable"}, + {"value": "AUTH_PASSWORD_DONT_MATCH", "message": "Les mot de passes ne correspondent pas"}, + {"value": "AUTH_SERVER_ERROR", "message": "Un problème est survenue avec le serveur d'authentification"}, + {"value": "AUTH_OLD_PASSWORD", "message": "Ancien mot de passe"}, + {"value": "AUTH_NEW_PASSWORD", "message": "Nouveau mot de passe"}, + {"value": "AUTH_CONF_PASSWORD", "message": "Confirmer le mot de passe"}, + {"value": "AUTH_CHANGE_PASSWORD", "message": "Changer le mot de passe"}, + {"value": "AUTH_INVALID_PASSWORD", "message": "Veuillez entrer un mot de passe valide"}, + {"value": "AUTH_INVALID_EMAIL", "message": "Veuillez entrer un email valide"}, + {"value": "CONTINUE_BUTTON", "message": "continuer"}, {"value": "CANCEL_BUTTON", "message": "annuler"}, {"value": "SEARCH_BUTTON", "message": "Rechercher"},