PASSAGGIO A VITE !
AGG. 1.1.23
This commit is contained in:
@@ -1,33 +1,23 @@
|
||||
// @ts-ignore
|
||||
// import { createI18n } from 'vue-i18n/index'
|
||||
import { createI18n } from 'vue-i18n/dist/vue-i18n.esm-bundler.js'
|
||||
import messages from '../statics/i18n'
|
||||
import { boot } from 'quasar/wrappers'
|
||||
// you'll need to create the src/i18n/index.js file too
|
||||
import { boot } from 'quasar/wrappers';
|
||||
import { createI18n } from 'vue-i18n';
|
||||
import messages from '../statics/i18n.js';
|
||||
|
||||
// Definisci i tipi per i messaggi
|
||||
export type MessageLanguages = keyof typeof messages;
|
||||
export type MessageSchema = typeof messages;
|
||||
|
||||
|
||||
// Crea l'istanza di i18n
|
||||
const i18n = createI18n({
|
||||
locale: 'it',
|
||||
locale: 'it', // Lingua predefinita
|
||||
legacy: false, // Usa la Composition API
|
||||
messages,
|
||||
})
|
||||
});
|
||||
|
||||
export default ({ app }: { app: any }) => {
|
||||
// Set i18n instance on app
|
||||
app.use(i18n)
|
||||
}
|
||||
// Esporta l'istanza di i18n
|
||||
export { i18n };
|
||||
|
||||
export function useI18n() {
|
||||
// eslint-disable-next-line @typescript-eslint/unbound-method
|
||||
const { t, te, tm, rt, d, n, ...globalApi } = i18n.global;
|
||||
|
||||
return {
|
||||
t: t.bind(i18n),
|
||||
te: te.bind(i18n),
|
||||
tm: tm.bind(i18n),
|
||||
rt: rt.bind(i18n),
|
||||
d: d.bind(i18n),
|
||||
n: n.bind(i18n),
|
||||
...globalApi,
|
||||
};
|
||||
}
|
||||
|
||||
export { i18n }
|
||||
// Usa i18n nel boot file di Quasar
|
||||
export default boot(({ app }) => {
|
||||
app.use(i18n);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user