2021-06-09 12:11:51 +02:00
|
|
|
import { prefixPluginTranslations } from '@strapi/helper-plugin';
|
2020-02-11 17:15:53 +01:00
|
|
|
import pluginPkg from '../../package.json';
|
|
|
|
import pluginId from './pluginId';
|
|
|
|
import pluginLogo from './assets/images/logo.svg';
|
|
|
|
|
2021-05-10 14:12:40 +02:00
|
|
|
const pluginDescription = pluginPkg.strapi.description || pluginPkg.description;
|
|
|
|
const icon = pluginPkg.strapi.icon;
|
|
|
|
const name = pluginPkg.strapi.name;
|
2020-02-11 17:15:53 +01:00
|
|
|
|
2021-05-10 14:12:40 +02:00
|
|
|
export default {
|
|
|
|
register(app) {
|
|
|
|
app.registerPlugin({
|
|
|
|
description: pluginDescription,
|
|
|
|
icon,
|
|
|
|
id: pluginId,
|
|
|
|
isReady: true,
|
|
|
|
isRequired: pluginPkg.strapi.required || false,
|
|
|
|
name,
|
|
|
|
pluginLogo,
|
|
|
|
});
|
|
|
|
},
|
2021-07-21 09:05:20 +02:00
|
|
|
bootstrap() {},
|
2021-06-09 11:22:23 +02:00
|
|
|
async registerTrads({ locales }) {
|
|
|
|
const importedTrads = await Promise.all(
|
|
|
|
locales.map(locale => {
|
|
|
|
return import(
|
|
|
|
/* webpackChunkName: "graphql-translation-[request]" */ `./translations/${locale}.json`
|
|
|
|
)
|
|
|
|
.then(({ default: data }) => {
|
|
|
|
return {
|
2021-06-09 12:11:51 +02:00
|
|
|
data: prefixPluginTranslations(data, pluginId),
|
2021-06-09 11:22:23 +02:00
|
|
|
locale,
|
|
|
|
};
|
|
|
|
})
|
|
|
|
.catch(() => {
|
|
|
|
return {
|
|
|
|
data: {},
|
|
|
|
locale,
|
|
|
|
};
|
|
|
|
});
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
|
|
|
return Promise.resolve(importedTrads);
|
|
|
|
},
|
2020-02-11 17:15:53 +01:00
|
|
|
};
|