47
js/src/utils/errors.ts
Normal file
47
js/src/utils/errors.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import { i18n } from '@/utils/i18n';
|
||||
|
||||
export const refreshSuggestion = i18n.t('Please refresh the page and retry.') as string;
|
||||
|
||||
export const defaultError: IError = {
|
||||
match: / /,
|
||||
value: i18n.t('An error has occurred.') as string,
|
||||
};
|
||||
|
||||
export interface IError { match: RegExp; value: string; suggestRefresh?: boolean; }
|
||||
|
||||
export const errors: IError[] = [
|
||||
{
|
||||
match: /^Event with UUID .* not found$/,
|
||||
value: i18n.t('Page not found') as string,
|
||||
suggestRefresh: false,
|
||||
},
|
||||
{
|
||||
match: /^Event not found$/,
|
||||
value: i18n.t('Event not found.') as string,
|
||||
},
|
||||
{
|
||||
match: /^Event with this ID .* doesn't exist$/,
|
||||
value: i18n.t('Event not found.') as string,
|
||||
},
|
||||
{
|
||||
match: /^Error while saving report$/,
|
||||
value: i18n.t('Error while saving report.') as string,
|
||||
},
|
||||
{
|
||||
match: /^Participant already has role rejected$/,
|
||||
value: i18n.t('Participant already was rejected.') as string,
|
||||
},
|
||||
{
|
||||
match: /^Participant already has role participant$/,
|
||||
value: i18n.t('Participant has already been approved as participant.') as string,
|
||||
},
|
||||
{
|
||||
match: /^You are already a participant of this event$/,
|
||||
value: i18n.t('You are already a participant of this event.') as string,
|
||||
},
|
||||
{
|
||||
match: /NetworkError when attempting to fetch resource.$/,
|
||||
value: i18n.t('Error while communicating with the server.') as string,
|
||||
},
|
||||
|
||||
];
|
||||
13
js/src/utils/i18n.ts
Normal file
13
js/src/utils/i18n.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import Vue from 'vue';
|
||||
import VueI18n from 'vue-i18n';
|
||||
import messages from '@/i18n/index';
|
||||
|
||||
const language = (window.navigator as any).userLanguage || window.navigator.language;
|
||||
|
||||
Vue.use(VueI18n);
|
||||
|
||||
export const i18n = new VueI18n({
|
||||
locale: language.split('-')[0], // set locale
|
||||
messages, // set locale messages
|
||||
fallbackLocale: 'en_US',
|
||||
});
|
||||
Reference in New Issue
Block a user