Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import Vue from 'vue';
import VueI18n from 'vue-i18n';
import en from '@/assets/locales/en.json';
import fr from '@/assets/locales/fr.json';
// const defaultImpl = VueI18n.prototype.getChoiceIndex;
// VueI18n.prototype.getChoiceIndex = function(choice, choicesLength) {
// // this === VueI18n instance, so the locale property also exists here
// if (this.locale !== 'fr') {
// // proceed to the default implementation
// return defaultImpl.apply(this, arguments)
// }
// if (choice === 0) {
// return 0;
// }
// const teen = choice > 10 && choice < 20;
// const endsWithOne = choice % 10 === 1;
// if (!teen && endsWithOne) {
// return 1;
// }
// if (!teen && choice % 10 >= 2 && choice % 10 <= 4) {
// return 2;
// }
// return (choicesLength < 4) ? 2 : 3;
// }
Vue.use(VueI18n);
const dateTimeFormats = {
'en': {
short: {
year: 'numeric',
month: 'short',
day: 'numeric'
}
},
'fr': {
short: {
year: 'numeric',
month: 'numeric',
day: 'numeric'
}
}
};
const numberFormats = {
'fr': {
currency: {
style: 'currency', currency: 'EUR'
}
}
};
const i18n = new VueI18n({
locale: process.env.VUE_APP_I18N_DEFAULT_LOCALE || 'fr',
fallbackLocale: process.env.VUE_APP_I18N_FALLBACK_LOCALE || 'fr',
messages: { en, fr },
dateTimeFormats,
numberFormats
});
export default i18n;