34 lines
909 B
JavaScript
Raw Normal View History

2021-01-22 17:57:15 +01:00
'use strict';
2021-02-15 11:24:28 +01:00
const { capitalize } = require('lodash/fp');
const { getService } = require('../../utils');
2021-01-25 20:58:33 +01:00
const actions = ['create', 'read', 'update', 'delete'].map(uid => ({
section: 'settings',
category: 'Internationalization',
subCategory: 'Locales',
pluginName: 'i18n',
displayName: capitalize(uid),
uid: `locale.${uid}`,
}));
module.exports = async () => {
2021-01-25 20:58:33 +01:00
const { actionProvider } = strapi.admin.services.permission;
actionProvider.register(actions);
2021-01-04 22:01:37 +01:00
getService('entity-service-decorator').decorate();
await getService('locales').initDefaultLocale();
2021-02-16 12:08:35 +01:00
Object.values(strapi.models)
.filter(model => getService('content-types').isLocalized(model))
.forEach(model => {
strapi.db.lifecycles.register({
model: model.uid,
async beforeCreate(data) {
await getService('localizations').assignDefaultLocale(data);
2021-02-16 12:08:35 +01:00
},
2021-02-12 12:23:51 +01:00
});
2021-02-16 12:08:35 +01:00
});
2021-02-12 12:23:51 +01:00
};