Better error messages on geolocation fetching errors

This commit is contained in:
Lucas Verney 2018-07-17 23:27:07 +02:00
parent b792f2ec44
commit 169076dffa
3 changed files with 16 additions and 1 deletions

View File

@ -17,8 +17,12 @@ export default {
upvote: 'Upvote',
},
geolocation: {
errorFetchingPosition: 'Error fetching your position:',
fetching: 'Fetching current position…',
geolocation: 'Geolocation',
permissionDenied: 'access to your position is denied.',
positionUnavailable: 'unable to retrieve your position.',
timeout: 'position was too long to acquire.',
unavailable: 'Sorry, geolocation is not available in your browser.',
},
intro: {

View File

@ -17,8 +17,12 @@ export default {
upvote: 'Confirmer',
},
geolocation: {
errorFetchingPosition: 'Impossible de récupérer votre position :',
fetching: 'En attente de votre position…',
geolocation: 'Géolocalisation',
permissionDenied: "l'accès a votre position a été refusé.",
positionUnavailable: 'impossible de déterminer votre position.',
timeout: 'votre position est trop longue à récupérer.',
unavailable: "Désolé, la géolocalisation n'est pas disponible dans votre navigateur.",
},
intro: {

View File

@ -139,7 +139,14 @@ export default {
}
},
handlePositionError(error) {
this.error = `Error ${error.code}: ${error.message}`;
this.error = `${this.$t('geolocation.errorFetchingPosition')} `;
if (error.code === 1) {
this.error += this.$t('geolocation.permissionDenied');
} else if (error.code === 2) {
this.error += this.$t('geolocation.positionUnavailable');
} else {
this.error += this.$t('geolocation.timeout');
}
},
setPosition(position) {
if (this.latLng) {