jws-frontend/src/boot/i18n.ts
Methapon Metanipat b0136bba4d
refactor: global shared state and function (#79)
* refactor: expose i18n instance

* feat: add global app utility function

* refactor: use global utility function

* refactor: avoid undefined when use outside vue

refactor: avoid undefined when use outside vue

* refactor: remove dup code and use util

* refactor: auto fetch option when use store
2024-11-21 11:55:44 +07:00

36 lines
1,012 B
TypeScript

import { boot } from 'quasar/wrappers';
import { createI18n } from 'vue-i18n';
import messages from 'src/i18n';
export type MessageLanguages = keyof typeof messages;
// Type-define 'eng' as the master schema for the resource
export type MessageSchema = (typeof messages)['eng'];
// See https://vue-i18n.intlify.dev/guide/advanced/typescript.html#global-resource-schema-type-definition
/* eslint-disable @typescript-eslint/no-empty-interface */
declare module 'vue-i18n' {
// define the locale messages schema
export interface DefineLocaleMessage extends MessageSchema {}
// define the datetime format schema
export interface DefineDateTimeFormat {}
// define the number format schema
export interface DefineNumberFormat {}
}
/* eslint-enable @typescript-eslint/no-empty-interface */
export const i18n = createI18n({
locale: 'tha',
legacy: false,
messages: {
'en-US': {},
...messages,
},
});
export default boot(({ app }) => {
// Set i18n instance on app
app.use(i18n);
});