@sodacore/i18n
Version:
Sodacore i18n is a plugin that offers internationalisation and localisation support for the Sodacore framework.
24 lines (23 loc) • 824 B
JavaScript
import { BasePlugin, Utils } from '@sodacore/core';
import { file } from 'bun';
import I18nService from '../service/i18n';
import I18nProvider from '../provider/i18n';
const packageJson = file(Utils.resolve(import.meta.dirname, '../../package.json'));
if (!await packageJson.exists())
throw new Error('Package.json not found.');
const packageMeta = await packageJson.json();
export default class I18nPlugin extends BasePlugin {
constructor(config = {}) {
super(config);
this.config = config;
this.name = packageMeta.name;
this.version = packageMeta.version;
this.description = packageMeta.description;
this.author = packageMeta.author;
this.setup();
}
async install(app) {
app.register(I18nProvider);
app.register(I18nService);
}
}