2021-06-15 13:08:03 +02:00
|
|
|
import { prefixPluginTranslations } from '@strapi/helper-plugin';
|
2019-10-10 11:45:26 +02:00
|
|
|
import pluginPkg from '../../package.json';
|
|
|
|
import pluginId from './pluginId';
|
2021-07-28 08:22:59 +02:00
|
|
|
import Initializer from './components/Initializer';
|
2021-05-12 11:51:12 +02:00
|
|
|
const pluginDescription = pluginPkg.strapi.description || pluginPkg.description;
|
|
|
|
const icon = pluginPkg.strapi.icon;
|
|
|
|
const name = pluginPkg.strapi.name;
|
2019-10-10 11:45:26 +02:00
|
|
|
|
2021-05-12 11:51:12 +02:00
|
|
|
export default {
|
|
|
|
register(app) {
|
2021-06-16 15:22:45 +02:00
|
|
|
app.addMenuLink({
|
|
|
|
to: `/plugins/${pluginId}`,
|
|
|
|
icon,
|
|
|
|
intlLabel: {
|
|
|
|
id: `${pluginId}.plugin.name`,
|
|
|
|
defaultMessage: name,
|
|
|
|
},
|
2021-07-28 08:22:59 +02:00
|
|
|
Component: async () => {
|
|
|
|
const component = await import(/* webpackChunkName: "[request]" */ './pages/App');
|
|
|
|
|
|
|
|
return component;
|
|
|
|
},
|
2021-06-16 15:22:45 +02:00
|
|
|
permissions: [
|
|
|
|
// Uncomment to set the permissions of the plugin here
|
|
|
|
// {
|
|
|
|
// action: '', // the action name should be plugins::plugin-name.actionType
|
|
|
|
// subject: null,
|
|
|
|
// },
|
|
|
|
],
|
|
|
|
});
|
2021-05-12 11:51:12 +02:00
|
|
|
app.registerPlugin({
|
|
|
|
description: pluginDescription,
|
|
|
|
icon,
|
|
|
|
id: pluginId,
|
|
|
|
initializer: Initializer,
|
|
|
|
isReady: false,
|
|
|
|
isRequired: pluginPkg.strapi.required || false,
|
|
|
|
name,
|
|
|
|
});
|
|
|
|
},
|
2021-07-21 09:05:20 +02:00
|
|
|
bootstrap(app) {},
|
2021-06-15 13:08:03 +02:00
|
|
|
async registerTrads({ locales }) {
|
|
|
|
const importedTrads = await Promise.all(
|
|
|
|
locales.map(locale => {
|
|
|
|
return import(`./translations/${locale}.json`)
|
|
|
|
.then(({ default: data }) => {
|
|
|
|
return {
|
|
|
|
data: prefixPluginTranslations(data, pluginId),
|
|
|
|
locale,
|
|
|
|
};
|
|
|
|
})
|
|
|
|
.catch(() => {
|
|
|
|
return {
|
|
|
|
data: {},
|
|
|
|
locale,
|
|
|
|
};
|
|
|
|
});
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
|
|
|
return Promise.resolve(importedTrads);
|
|
|
|
},
|
2019-10-10 11:45:26 +02:00
|
|
|
};
|