forked from vergnet/application-amicale
Added translations for login screen
This commit is contained in:
parent
1c473a1712
commit
d7d6146245
5 changed files with 72 additions and 23 deletions
|
@ -51,19 +51,19 @@ class SideBar extends React.PureComponent<Props, State> {
|
||||||
route: "Divider4"
|
route: "Divider4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'LOGIN',
|
name: i18n.t('screens.login'),
|
||||||
route: "LoginScreen",
|
route: "LoginScreen",
|
||||||
icon: "login",
|
icon: "login",
|
||||||
onlyWhenLoggedOut: true,
|
onlyWhenLoggedOut: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'PROFILE',
|
name: i18n.t('screens.profile'),
|
||||||
route: "ProfileScreen",
|
route: "ProfileScreen",
|
||||||
icon: "account",
|
icon: "account",
|
||||||
onlyWhenLoggedIn: true,
|
onlyWhenLoggedIn: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'DISCONNECT',
|
name: i18n.t('screens.logout'),
|
||||||
route: 'disconnect',
|
route: 'disconnect',
|
||||||
action: () => this.onClickDisconnect(),
|
action: () => this.onClickDisconnect(),
|
||||||
icon: "logout",
|
icon: "logout",
|
||||||
|
|
|
@ -203,7 +203,7 @@ function LoginStackComponent() {
|
||||||
options={({navigation}) => {
|
options={({navigation}) => {
|
||||||
const openDrawer = getDrawerButton.bind(this, navigation);
|
const openDrawer = getDrawerButton.bind(this, navigation);
|
||||||
return {
|
return {
|
||||||
title: 'LOGIN',
|
title: i18n.t('screens.login'),
|
||||||
headerLeft: openDrawer
|
headerLeft: openDrawer
|
||||||
};
|
};
|
||||||
}}
|
}}
|
||||||
|
@ -227,7 +227,7 @@ function ProfileStackComponent() {
|
||||||
options={({navigation}) => {
|
options={({navigation}) => {
|
||||||
const openDrawer = getDrawerButton.bind(this, navigation);
|
const openDrawer = getDrawerButton.bind(this, navigation);
|
||||||
return {
|
return {
|
||||||
title: 'PROFILE',
|
title: i18n.t('screens.profile'),
|
||||||
headerLeft: openDrawer
|
headerLeft: openDrawer
|
||||||
};
|
};
|
||||||
}}
|
}}
|
||||||
|
|
|
@ -13,6 +13,7 @@ import {
|
||||||
import {Avatar, Button, Card, HelperText, Text, TextInput, withTheme} from 'react-native-paper';
|
import {Avatar, Button, Card, HelperText, Text, TextInput, withTheme} from 'react-native-paper';
|
||||||
import ConnectionManager, {ERROR_TYPE} from "../../managers/ConnectionManager";
|
import ConnectionManager, {ERROR_TYPE} from "../../managers/ConnectionManager";
|
||||||
import {openBrowser} from "../../utils/WebBrowser";
|
import {openBrowser} from "../../utils/WebBrowser";
|
||||||
|
import i18n from 'i18n-js';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
navigation: Object,
|
navigation: Object,
|
||||||
|
@ -137,31 +138,33 @@ class LoginScreen extends React.Component<Props, State> {
|
||||||
}
|
}
|
||||||
|
|
||||||
handleErrors(error: number) {
|
handleErrors(error: number) {
|
||||||
|
const title = i18n.t("loginScreen.errors.title");
|
||||||
|
let message;
|
||||||
switch (error) {
|
switch (error) {
|
||||||
case ERROR_TYPE.CONNECTION_ERROR:
|
case ERROR_TYPE.CONNECTION_ERROR:
|
||||||
Alert.alert('ERREUR', 'PB DE CONNEXION');
|
message = i18n.t("loginScreen.errors.connection");
|
||||||
break;
|
break;
|
||||||
case ERROR_TYPE.BAD_CREDENTIALS:
|
case ERROR_TYPE.BAD_CREDENTIALS:
|
||||||
Alert.alert('ERREUR', 'MDP OU MAIL INVALIDE');
|
message = i18n.t("loginScreen.errors.credentials");
|
||||||
break;
|
break;
|
||||||
case ERROR_TYPE.SAVE_TOKEN:
|
case ERROR_TYPE.SAVE_TOKEN:
|
||||||
Alert.alert('ERREUR', 'IMPOSSIBLE DE SAUVEGARDER INFOS CONNEXION');
|
message = i18n.t("loginScreen.errors.saveToken");
|
||||||
break;
|
break;
|
||||||
case ERROR_TYPE.NO_CONSENT:
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
Alert.alert('ERREUR', 'ERREUR INCONNUE. CONTACTER ARNAUD');
|
message = i18n.t("loginScreen.errors.unknown");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Alert.alert(title, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
getFormInput() {
|
getFormInput() {
|
||||||
return (
|
return (
|
||||||
<View>
|
<View>
|
||||||
<TextInput
|
<TextInput
|
||||||
label='Email'
|
label={i18n.t("loginScreen.email")}
|
||||||
mode='outlined'
|
mode='outlined'
|
||||||
value={this.state.email}
|
value={this.state.email}
|
||||||
onChangeText={this.onEmailChange}
|
onChangeText={this.onEmailChange}
|
||||||
|
@ -180,13 +183,13 @@ class LoginScreen extends React.Component<Props, State> {
|
||||||
type="error"
|
type="error"
|
||||||
visible={this.shouldShowEmailError()}
|
visible={this.shouldShowEmailError()}
|
||||||
>
|
>
|
||||||
EMAIL INVALID
|
{i18n.t("loginScreen.emailError")}
|
||||||
</HelperText>
|
</HelperText>
|
||||||
<TextInput
|
<TextInput
|
||||||
ref={(ref) => {
|
ref={(ref) => {
|
||||||
this.passwordInputRef = ref;
|
this.passwordInputRef = ref;
|
||||||
}}
|
}}
|
||||||
label='Password'
|
label={i18n.t("loginScreen.password")}
|
||||||
mode='outlined'
|
mode='outlined'
|
||||||
value={this.state.password}
|
value={this.state.password}
|
||||||
onChangeText={this.onPasswordChange}
|
onChangeText={this.onPasswordChange}
|
||||||
|
@ -205,7 +208,7 @@ class LoginScreen extends React.Component<Props, State> {
|
||||||
type="error"
|
type="error"
|
||||||
visible={this.shouldShowPasswordError()}
|
visible={this.shouldShowPasswordError()}
|
||||||
>
|
>
|
||||||
PLS ENTER PASSWORD
|
{i18n.t("loginScreen.passwordError")}
|
||||||
</HelperText>
|
</HelperText>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
|
@ -215,8 +218,8 @@ class LoginScreen extends React.Component<Props, State> {
|
||||||
return (
|
return (
|
||||||
<Card style={styles.card}>
|
<Card style={styles.card}>
|
||||||
<Card.Title
|
<Card.Title
|
||||||
title="COUCOU"
|
title={i18n.t("loginScreen.title")}
|
||||||
subtitle="ENTREZ VOS IDENTIFIANTS"
|
subtitle={i18n.t("loginScreen.subtitle")}
|
||||||
left={(props) => <Avatar.Image
|
left={(props) => <Avatar.Image
|
||||||
{...props}
|
{...props}
|
||||||
source={ICON_AMICALE}
|
source={ICON_AMICALE}
|
||||||
|
@ -232,7 +235,7 @@ class LoginScreen extends React.Component<Props, State> {
|
||||||
loading={this.state.loading}
|
loading={this.state.loading}
|
||||||
onPress={this.onSubmit}
|
onPress={this.onSubmit}
|
||||||
style={{marginLeft: 'auto'}}>
|
style={{marginLeft: 'auto'}}>
|
||||||
LOGIN
|
{i18n.t("loginScreen.login")}
|
||||||
</Button>
|
</Button>
|
||||||
</Card.Actions>
|
</Card.Actions>
|
||||||
</Card.Content>
|
</Card.Content>
|
||||||
|
@ -244,17 +247,17 @@ class LoginScreen extends React.Component<Props, State> {
|
||||||
return (
|
return (
|
||||||
<Card style={styles.card}>
|
<Card style={styles.card}>
|
||||||
<Card.Content>
|
<Card.Content>
|
||||||
<Text>MDP OUBLIÉ ? t'es pas doué</Text>
|
<Text>{i18n.t("loginScreen.forgotPassword")}</Text>
|
||||||
<View style={styles.btnContainer}>
|
<View style={styles.btnContainer}>
|
||||||
<Button
|
<Button
|
||||||
icon="reload"
|
icon="reload"
|
||||||
mode="contained"
|
mode="contained"
|
||||||
onPress={this.onResetPasswordClick}
|
onPress={this.onResetPasswordClick}
|
||||||
style={{marginLeft: 'auto'}}>
|
style={{marginLeft: 'auto'}}>
|
||||||
RESET MDP
|
{i18n.t("loginScreen.resetPassword")}
|
||||||
</Button>
|
</Button>
|
||||||
</View>
|
</View>
|
||||||
<Text>PAS DE COMPTE ? DOMMAGE PASSE À L'AMICALE</Text>
|
<Text>{i18n.t("loginScreen.noAccount")}</Text>
|
||||||
</Card.Content>
|
</Card.Content>
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
|
|
|
@ -12,7 +12,10 @@
|
||||||
"bluemind": "INSA Mails",
|
"bluemind": "INSA Mails",
|
||||||
"ent": "INSA ENT",
|
"ent": "INSA ENT",
|
||||||
"about": "About",
|
"about": "About",
|
||||||
"debug": "Debug"
|
"debug": "Debug",
|
||||||
|
"login": "Login",
|
||||||
|
"logout": "Logout",
|
||||||
|
"profile": "Profile"
|
||||||
},
|
},
|
||||||
"sidenav": {
|
"sidenav": {
|
||||||
"divider1": "Student websites",
|
"divider1": "Student websites",
|
||||||
|
@ -207,6 +210,26 @@
|
||||||
"computerRoom": "Computer",
|
"computerRoom": "Computer",
|
||||||
"bibRoom": "Bib'Box"
|
"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": {
|
"general": {
|
||||||
"loading": "Loading...",
|
"loading": "Loading...",
|
||||||
"networkError": "Unable to contact servers. Make sure you are connected to Internet."
|
"networkError": "Unable to contact servers. Make sure you are connected to Internet."
|
||||||
|
|
|
@ -12,7 +12,10 @@
|
||||||
"bluemind": "Mails INSA",
|
"bluemind": "Mails INSA",
|
||||||
"ent": "ENT INSA",
|
"ent": "ENT INSA",
|
||||||
"about": "À Propos",
|
"about": "À Propos",
|
||||||
"debug": "Debug"
|
"debug": "Debug",
|
||||||
|
"login": "Se connecter",
|
||||||
|
"logout": "Se déconnecter",
|
||||||
|
"profile": "Profile"
|
||||||
},
|
},
|
||||||
"sidenav": {
|
"sidenav": {
|
||||||
"divider1": "Sites étudiants",
|
"divider1": "Sites étudiants",
|
||||||
|
@ -208,6 +211,26 @@
|
||||||
"computerRoom": "Ordi",
|
"computerRoom": "Ordi",
|
||||||
"bibRoom": "Bib'Box"
|
"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": {
|
"general": {
|
||||||
"loading": "Chargement...",
|
"loading": "Chargement...",
|
||||||
"networkError": "Impossible de contacter les serveurs. Assurez-vous d'être connecté à internet."
|
"networkError": "Impossible de contacter les serveurs. Assurez-vous d'être connecté à internet."
|
||||||
|
|
Loading…
Reference in a new issue