Files
hoppscotch/packages/hoppscotch-sh-admin/src/modules/i18n.ts
2024-03-28 20:17:24 +05:30

36 lines
674 B
TypeScript

import { I18n, createI18n } from 'vue-i18n';
import { HoppModule } from '.';
import messages from '@intlify/unplugin-vue-i18n/messages';
// A reference to the i18n instance
let i18nInstance: I18n<
Record<string, unknown>,
Record<string, unknown>,
Record<string, unknown>,
string,
false
> | null = null;
/**
* Returns the i18n instance
*/
export function getI18n() {
return i18nInstance!.global.t;
}
export default <HoppModule>{
onVueAppInit(app) {
const i18n = createI18n({
locale: 'en',
messages,
fallbackLocale: 'en',
legacy: false,
allowComposition: true,
});
app.use(i18n);
i18nInstance = i18n;
},
};