Added translations for login screen

This commit is contained in:
Arnaud Vergnet 2020-03-31 20:40:52 +02:00
parent 1c473a1712
commit d7d6146245
5 changed files with 72 additions and 23 deletions

View file

@ -51,19 +51,19 @@ class SideBar extends React.PureComponent<Props, State> {
route: "Divider4"
},
{
name: 'LOGIN',
name: i18n.t('screens.login'),
route: "LoginScreen",
icon: "login",
onlyWhenLoggedOut: true,
},
{
name: 'PROFILE',
name: i18n.t('screens.profile'),
route: "ProfileScreen",
icon: "account",
onlyWhenLoggedIn: true,
},
{
name: 'DISCONNECT',
name: i18n.t('screens.logout'),
route: 'disconnect',
action: () => this.onClickDisconnect(),
icon: "logout",

View file

@ -203,7 +203,7 @@ function LoginStackComponent() {
options={({navigation}) => {
const openDrawer = getDrawerButton.bind(this, navigation);
return {
title: 'LOGIN',
title: i18n.t('screens.login'),
headerLeft: openDrawer
};
}}
@ -227,7 +227,7 @@ function ProfileStackComponent() {
options={({navigation}) => {
const openDrawer = getDrawerButton.bind(this, navigation);
return {
title: 'PROFILE',
title: i18n.t('screens.profile'),
headerLeft: openDrawer
};
}}

View file

@ -13,6 +13,7 @@ import {
import {Avatar, Button, Card, HelperText, Text, TextInput, withTheme} from 'react-native-paper';
import ConnectionManager, {ERROR_TYPE} from "../../managers/ConnectionManager";
import {openBrowser} from "../../utils/WebBrowser";
import i18n from 'i18n-js';
type Props = {
navigation: Object,
@ -137,31 +138,33 @@ class LoginScreen extends React.Component<Props, State> {
}
handleErrors(error: number) {
const title = i18n.t("loginScreen.errors.title");
let message;
switch (error) {
case ERROR_TYPE.CONNECTION_ERROR:
Alert.alert('ERREUR', 'PB DE CONNEXION');
message = i18n.t("loginScreen.errors.connection");
break;
case ERROR_TYPE.BAD_CREDENTIALS:
Alert.alert('ERREUR', 'MDP OU MAIL INVALIDE');
message = i18n.t("loginScreen.errors.credentials");
break;
case ERROR_TYPE.SAVE_TOKEN:
Alert.alert('ERREUR', 'IMPOSSIBLE DE SAUVEGARDER INFOS CONNEXION');
message = i18n.t("loginScreen.errors.saveToken");
break;
case ERROR_TYPE.NO_CONSENT:
Alert.alert('ERREUR', 'VOUS N\'AVEZ PAS DONNÉ VOTRE CONSENTEMENT POUR LES DONNÉES');
message = i18n.t("loginScreen.errors.consent");
break;
default:
Alert.alert('ERREUR', 'ERREUR INCONNUE. CONTACTER ARNAUD');
message = i18n.t("loginScreen.errors.unknown");
break;
}
Alert.alert(title, message);
}
getFormInput() {
return (
<View>
<TextInput
label='Email'
label={i18n.t("loginScreen.email")}
mode='outlined'
value={this.state.email}
onChangeText={this.onEmailChange}
@ -180,13 +183,13 @@ class LoginScreen extends React.Component<Props, State> {
type="error"
visible={this.shouldShowEmailError()}
>
EMAIL INVALID
{i18n.t("loginScreen.emailError")}
</HelperText>
<TextInput
ref={(ref) => {
this.passwordInputRef = ref;
}}
label='Password'
label={i18n.t("loginScreen.password")}
mode='outlined'
value={this.state.password}
onChangeText={this.onPasswordChange}
@ -205,7 +208,7 @@ class LoginScreen extends React.Component<Props, State> {
type="error"
visible={this.shouldShowPasswordError()}
>
PLS ENTER PASSWORD
{i18n.t("loginScreen.passwordError")}
</HelperText>
</View>
);
@ -215,8 +218,8 @@ class LoginScreen extends React.Component<Props, State> {
return (
<Card style={styles.card}>
<Card.Title
title="COUCOU"
subtitle="ENTREZ VOS IDENTIFIANTS"
title={i18n.t("loginScreen.title")}
subtitle={i18n.t("loginScreen.subtitle")}
left={(props) => <Avatar.Image
{...props}
source={ICON_AMICALE}
@ -232,7 +235,7 @@ class LoginScreen extends React.Component<Props, State> {
loading={this.state.loading}
onPress={this.onSubmit}
style={{marginLeft: 'auto'}}>
LOGIN
{i18n.t("loginScreen.login")}
</Button>
</Card.Actions>
</Card.Content>
@ -244,17 +247,17 @@ class LoginScreen extends React.Component<Props, State> {
return (
<Card style={styles.card}>
<Card.Content>
<Text>MDP OUBLIÉ ? t'es pas doué</Text>
<Text>{i18n.t("loginScreen.forgotPassword")}</Text>
<View style={styles.btnContainer}>
<Button
icon="reload"
mode="contained"
onPress={this.onResetPasswordClick}
style={{marginLeft: 'auto'}}>
RESET MDP
{i18n.t("loginScreen.resetPassword")}
</Button>
</View>
<Text>PAS DE COMPTE ? DOMMAGE PASSE À L'AMICALE</Text>
<Text>{i18n.t("loginScreen.noAccount")}</Text>
</Card.Content>
</Card>
);

View file

@ -12,7 +12,10 @@
"bluemind": "INSA Mails",
"ent": "INSA ENT",
"about": "About",
"debug": "Debug"
"debug": "Debug",
"login": "Login",
"logout": "Logout",
"profile": "Profile"
},
"sidenav": {
"divider1": "Student websites",
@ -207,6 +210,26 @@
"computerRoom": "Computer",
"bibRoom": "Bib'Box"
},
"loginScreen": {
"title": "Amicale account",
"subtitle": "Please enter your credentials",
"email": "Email",
"emailError": "Please enter a valid email",
"password": "Password",
"passwordError": "Please enter a password",
"login": "Login",
"forgotPassword": "Forgot your password? Click on the button below to get a new one.",
"resetPassword": "Reset Password",
"noAccount": "No Account? Go to the Amicale's building during open hours to create one.",
"errors": {
"title": "Error!",
"connection": "Network error. Please check your internet connection.",
"credentials": "Email or password invalid.",
"saveToken": "Failed to save connection information, please contact support.",
"consent": "You did not give your consent for data processing to the Amicale.",
"unknown": "Unknown error, please contact support."
}
},
"general": {
"loading": "Loading...",
"networkError": "Unable to contact servers. Make sure you are connected to Internet."

View file

@ -12,7 +12,10 @@
"bluemind": "Mails INSA",
"ent": "ENT INSA",
"about": "À Propos",
"debug": "Debug"
"debug": "Debug",
"login": "Se connecter",
"logout": "Se déconnecter",
"profile": "Profile"
},
"sidenav": {
"divider1": "Sites étudiants",
@ -208,6 +211,26 @@
"computerRoom": "Ordi",
"bibRoom": "Bib'Box"
},
"loginScreen": {
"title": "Compte Amicale",
"subtitle": "Entrez vos identifiants",
"email": "Email",
"emailError": "Merci d'entrer un email valide",
"password": "Mot de passe",
"passwordError": "Merci d'entrer un mot de passe",
"login": "Se Connecter",
"forgotPassword": "Mot de passe oublié ? Cliquez sur le bouton ci-dessous pour en créer un nouveau.",
"resetPassword": "Réinitialiser mot de passe",
"noAccount": "Pas de compte ? Passez à l'Amicale pendant une perm pour en créer un.",
"errors": {
"title": "Erreur !",
"connection": "Erreur de réseau. Merci de vérifier votre connexion Internet.",
"credentials": "Email ou mot de passe invalide.",
"saveToken": "Erreur de sauvegarde des informations de connexion, merci de contacter le support.",
"consent": "Vous n'avez pas donné votre consentement pour l'utilisation de vos données personnelles.",
"unknown": "Erreur inconnue, merci de contacter le support."
}
},
"general": {
"loading": "Chargement...",
"networkError": "Impossible de contacter les serveurs. Assurez-vous d'être connecté à internet."